Summary: | crash in malloc with ld.lld and -Wl,--export-dynamic -static | ||
---|---|---|---|
Product: | Base System | Reporter: | Andrew "RhodiumToad" Gierth <andrew> |
Component: | bin | Assignee: | freebsd-toolchain (Nobody) <toolchain> |
Status: | Open --- | ||
Severity: | Affects Some People | CC: | arichardson, emacsray, emaste, freebsd, kevans, toolchain |
Priority: | --- | Keywords: | crash, needs-patch, needs-qa |
Version: | 12.0-STABLE | Flags: | koobs:
mfc-stable13?
koobs: mfc-stable12? koobs: mfc-stable11- |
Hardware: | Any | ||
OS: | Any | ||
URL: | https://reviews.llvm.org/D42748 | ||
Bug Depends on: | |||
Bug Blocks: | 231882 |
Description
Andrew "RhodiumToad" Gierth
2019-03-02 18:58:42 UTC
Kicking it over to -toolchain@ We also ran into this problem in CheriBSD. The binary is actually static (but file will report it as dynamically linked). However, it has a PT_DYNAMIC header and the symbol _DYNAMIC does not resolve to zero. This causes these crashes because there are various checks in libc, csu code, etc. that assume that `if (&_DYNAMIC == NULL)` is true the binary is statically linked and otherwise it assumes we are running a dynamic binary. For our CHERI compilers I just modified ld.lld to not emit _DYNAMIC and the PT_DYNAMIC header. I also attempted to upstream this fix but haven't got around to committing it since I'm not 100% sure what the correct behaviour is. See also https://reviews.llvm.org/D42748 Replied in https://reviews.llvm.org/D42748#1510087 :) moving away from &_DYNAMIC will be a more reliable approach. To check if an executable is dynamically linked, inspecting PT_INTERP is a better choice. IMO this needs to be addressed in lld. Discussion is happening in LLVM review D42748. (In reply to Ed Maste from comment #4) Commented at https://reviews.llvm.org/D42748#1637598 I think libc should probably be changed. That will also benefit future static PIE work. ^Triage: Correct review url (s/freebsd/llvm) and move to URL (see also only takes freebsd review urls) Correct URL reference (reviews.llvm.org, not reviews.freebsd.org) |