https://llvm.org/bugs/show_bug.cgi?id=31221
Bug ID: 31221 Summary: lld-linked FreeBSD/amd64 rtld segfaults after lld r288107 Product: lld Version: unspecified Hardware: PC OS: FreeBSD Status: NEW Severity: normal Priority: P Component: ELF Assignee: unassignedb...@nondot.org Reporter: ema...@freebsd.org CC: llvm-bugs@lists.llvm.org Blocks: 23214 Classification: Unclassified I built a FreeBSD installation using lld @ r288228 as the linker, and almost all userland binaries segfaulted when starting up, in rtld. Bisecting identified r288107 as the culprit. The problem is not reproducible after switching back to a rtld linked with lld built at r288102. The difference is that rtld built with post-r288107 lld has an entirely zeroed .got: % diffoscope old-lld/ld-elf.so.1 new-lld/ld-elf.so.1 --- old-lld/ld-elf.so.1 +++ new-lld/ld-elf.so.1 ├── readelf --wide --hex-dump=.got {} │ @@ -1,16 +1,16 @@ │ │ Hex dump of section '.got': │ - 0x00020410 20900000 00000000 70100200 00000000 .......p....... │ - 0x00020420 e0230200 00000000 e8230200 00000000 .#.......#...... │ - 0x00020430 10030200 00000000 d0b60000 00000000 ................ │ - 0x00020440 18240200 00000000 18230200 00000000 .$.......#...... │ - 0x00020450 68240200 00000000 6c240200 00000000 h$......l$...... │ - 0x00020460 70240200 00000000 74240200 00000000 p$......t$...... │ - 0x00020470 80100200 00000000 18060000 00000000 ................ │ - 0x00020480 00000200 00000000 7c240200 00000000 ........|$...... │ - 0x00020490 10240200 00000000 00100200 00000000 .$.............. │ - 0x000204a0 04100200 00000000 10100200 00000000 ................ │ - 0x000204b0 30160200 00000000 981b0200 00000000 0............... │ - 0x000204c0 b0100200 00000000 00240200 00000000 .........$...... │ - 0x000204d0 60240200 00000000 84240200 00000000 `$.......$...... │ - 0x000204e0 f8230200 00000000 .#...... │ + 0x00020410 00000000 00000000 00000000 00000000 ................ │ + 0x00020420 00000000 00000000 00000000 00000000 ................ │ + 0x00020430 00000000 00000000 00000000 00000000 ................ │ + 0x00020440 00000000 00000000 00000000 00000000 ................ │ + 0x00020450 00000000 00000000 00000000 00000000 ................ │ + 0x00020460 00000000 00000000 00000000 00000000 ................ │ + 0x00020470 00000000 00000000 00000000 00000000 ................ │ + 0x00020480 00000000 00000000 00000000 00000000 ................ │ + 0x00020490 00000000 00000000 00000000 00000000 ................ │ + 0x000204a0 00000000 00000000 00000000 00000000 ................ │ + 0x000204b0 00000000 00000000 00000000 00000000 ................ │ + 0x000204c0 00000000 00000000 00000000 00000000 ................ │ + 0x000204d0 00000000 00000000 00000000 00000000 ................ │ + 0x000204e0 00000000 00000000 ........ ├── readelf --wide --string-dump=.comment {} │ @@ -1,6 +1,6 @@ │ │ String dump of section '.comment': │ [ 1] FreeBSD clang version 3.9.0 (tags/RELEASE_390/final 280324) (based on LLVM 3.9.0) │ [ 53] $FreeBSD$ │ - [ 5d] Linker: LLD 4.0.0 (http://llvm.org/git/lld 01db8ccdad26c748727d9638c5df3b99c8260ddc) │ + [ 5d] Linker: LLD 4.0.0 (http://llvm.org/git/lld 326233f95ee6b9c32f19d04ad06a6c369e6acc5a) │ ├── readelf --wide --hex-dump=.gnu_debuglink {} │ @@ -1,4 +1,4 @@ │ │ Hex dump of section '.gnu_debuglink': │ 0x00000000 6c642d65 6c662e73 6f2e312e 64656275 ld-elf.so.1.debu │ - 0x00000010 67000000 a26ecfb2 g....n.. │ + 0x00000010 67000000 c1a333a6 g.....3. ╵ rtld has code to determine if it needs to relocate itself or not, which defaults to #ifndef RTLD_IS_DYNAMIC #define RTLD_IS_DYNAMIC() (&_DYNAMIC != NULL) #endif RTLD_IS_DYNAMIC is false when linked with lld >= r288107, so rtld does not apply its own relocations at startup and crashes. This is arguably a FreeBSD rtld bug (and we could address it there). I'm submitting this LLD ticket for tracking the issue as it may affect other projects. -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs