Skip to content

Commit

Permalink
Restore the binary compatibility for link_map l_addr.
Browse files Browse the repository at this point in the history
Keep link_map l_addr binary layout compatible, rename l_addr to l_base
where rtld returns map base.  Provide relocbase in newly added l_addr.

This effectively reverts the patch to the initial version of D24918.

Reported by: antoine (portmgr)
Reviewed by:	jhb, markj
Tested by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D24946
  • Loading branch information
kostikbel committed May 21, 2020
1 parent e68cde5 commit d0ca9a7
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
8 changes: 7 additions & 1 deletion cddl/contrib/opensolaris/lib/libdtrace/common/drti.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,18 @@ dtrace_dof_init(void)
return;
}

#ifdef __FreeBSD__
elf = (void *)lmp->l_base;
#else
elf = (void *)lmp->l_addr;
#endif

dh.dofhp_dof = (uintptr_t)dof;
dh.dofhp_addr = elf->e_type == ET_DYN ? (uintptr_t) lmp->l_addr : 0;
#ifdef __FreeBSD__
dh.dofhp_addr = elf->e_type == ET_DYN ? (uintptr_t) lmp->l_base : 0;
dh.dofhp_pid = getpid();
#else
dh.dofhp_addr = elf->e_type == ET_DYN ? (uintptr_t) lmp->l_addr : 0;
#endif

if (lmid == 0) {
Expand Down
13 changes: 8 additions & 5 deletions lib/libc/gen/dlinfo.3
Original file line number Diff line number Diff line change
Expand Up @@ -105,17 +105,16 @@ structure is defined in
.In link.h
and has the following members:
.Bd -literal -offset indent
caddr_t l_addr; /* Load Offset of library */
caddr_t l_base; /* Base Address of library */
const char *l_name; /* Absolute Path to Library */
const void *l_ld; /* Pointer to .dynamic in memory */
struct link_map *l_next, /* linked list of mapped libs */
*l_prev;
caddr_t l_addr; /* Load Offset of library */
.Ed
.Bl -tag -width ".Va l_addr"
.It Va l_addr
The load offset of the object, that is, the difference between
the actual load address and the base virtual address the object
was linked at.
.It Va l_base
The base address of the object loaded into memory.
.It Va l_name
The full name of the loaded shared object.
.It Va l_ld
Expand All @@ -130,6 +129,10 @@ structure on the link-map list.
The previous
.Vt Link_map
structure on the link-map list.
.It Va l_addr
The load offset of the object, that is, the difference between
the actual load address and the base virtual address the object
was linked at.
.El
.It Dv RTLD_DI_SERINFO
Retrieve the library search paths associated with the given
Expand Down
3 changes: 2 additions & 1 deletion libexec/rtld-elf/rtld.c
Original file line number Diff line number Diff line change
Expand Up @@ -4032,8 +4032,9 @@ linkmap_add(Obj_Entry *obj)
struct link_map *prev;

obj->linkmap.l_name = obj->path;
obj->linkmap.l_addr = obj->relocbase;
obj->linkmap.l_base = obj->mapbase;
obj->linkmap.l_ld = obj->dynamic;
obj->linkmap.l_addr = obj->relocbase;

if (r_debug.r_map == NULL) {
r_debug.r_map = l;
Expand Down
3 changes: 2 additions & 1 deletion sys/sys/link_elf.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,14 @@
#define LA_SER_SECURE 0x80 /* default (secure) path prepended */

typedef struct link_map {
caddr_t l_addr; /* Load Offset of library */
caddr_t l_base; /* Base Address of library */
#ifdef __mips__
caddr_t l_xxx; /* unused */
#endif
const char *l_name; /* Absolute Path to Library */
const void *l_ld; /* Pointer to .dynamic in memory */
struct link_map *l_next, *l_prev; /* linked list of of mapped libs */
caddr_t l_addr; /* Load Offset of library */
} Link_map;

struct r_debug {
Expand Down

0 comments on commit d0ca9a7

Please sign in to comment.