Page MenuHomeFreeBSD

Revert to the initial version of D24918
ClosedPublic

Authored by kib on May 21 2020, 5:30 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mar 12 2024, 6:44 AM
Unknown Object (File)
Jan 5 2024, 4:40 PM
Unknown Object (File)
Dec 20 2023, 8:04 AM
Unknown Object (File)
Nov 23 2023, 9:54 PM
Unknown Object (File)
Nov 8 2023, 7:33 PM
Unknown Object (File)
Nov 5 2023, 8:07 AM
Unknown Object (File)
Nov 3 2023, 5:29 AM
Unknown Object (File)
Oct 3 2023, 6:29 PM
Subscribers

Details

Summary

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.

Reported by: antoine (portmgr)

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

kib requested review of this revision.May 21 2020, 5:30 PM
cddl/contrib/opensolaris/lib/libdtrace/common/drti.c
146 ↗(On Diff #72081)

This needs to change too.

kib marked an inline comment as done.

FIx bug pointed by Mark.

This fixes the problem for me.

sys/sys/link_elf.h
63 ↗(On Diff #72082)

The patch got mangled somehow here.

lib/libc/gen/dlinfo.3
136 ↗(On Diff #72083)

I wonder if it's worth a note here about other operating systems? I wouldn't want to say "Linux does this, Solaris does this" because it's not our place and might get out of date. But maybe a note that other operating systems implement these perhaps with different semantics? I don't mind taking a stab at a suitable note after you commit this.

GDB will work with this ok. (It will still use l_base as it's l_addr, but that's ok)

In D24946#549258, @jhb wrote:

GDB will work with this ok. (It will still use l_base as it's l_addr, but that's ok)

Recompiled gdb would use new l_addr, isn't it ?

lib/libc/gen/dlinfo.3
136 ↗(On Diff #72083)

I verified that Linux does the same as our 'new' l_addr, but I am not sure about Solaris.
This review started because apparently dtrace depends on the old behavior, and Mark stated that the code is not changed against Solaris origin.

I was not able to find a Solaris box with fresh clang/lld to test (I cannot easily build a specific dso needed for test with GNU ld, and I do not have Solaris available at all). I do not block this fix while searching for a way to test Solaris.

This revision was not accepted when it landed; it landed in state Needs Review.May 21 2020, 10:24 PM
This revision was automatically updated to reflect the committed changes.
lib/libc/gen/dlinfo.3
136 ↗(On Diff #72083)

Exactly, I don't want to have a treatise on these fields in all operating systems - primarily a caution that these may behave differently on different operating systems so pay careful attention to the descriptions.

In D24946#549323, @kib wrote:
In D24946#549258, @jhb wrote:

GDB will work with this ok. (It will still use l_base as it's l_addr, but that's ok)

Recompiled gdb would use new l_addr, isn't it ?

No, it doesn't use the source layout. Instead, it uses functions that determine the binary layout so that it works for cross-debugging. This is part of why removing l_offs (now l_xxx) for MIPS would be such a PITA. For example, all of the non-MIPS architectures on FreeBSD use these functions to describe the layout of 'struct link_map':

https://github.com/bsdjhb/gdb/blob/master/gdb/solib-svr4.c#L3160 and https://github.com/bsdjhb/gdb/blob/master/gdb/solib-svr4.c#L3192

MIPS on FreeBSD uses its own versions of these functions that account for l_offs:

https://github.com/bsdjhb/gdb/blob/master/gdb/mips-fbsd-tdep.c#L465

Note that these files are all "non-native" meaning they get compiled on FreeBSD/amd64 hosts as well as Linux or OS X or Windows hosts to permit cross-debugging of process cores which is why they do not use the native structure at all, but instead hardcode knowledge about the layout of those structures.