[llvm-bugs] [Bug 26712] New: PHDR & section mismatch in lld-linked static hello world on FreeBSD results in segfault
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Feb 23 06:03:39 PST 2016
https://llvm.org/bugs/show_bug.cgi?id=26712
Bug ID: 26712
Summary: PHDR & section mismatch in lld-linked static hello
world on FreeBSD results in segfault
Product: lld
Version: unspecified
Hardware: PC
OS: FreeBSD
Status: NEW
Severity: normal
Priority: P
Component: All Bugs
Assignee: unassignedbugs at nondot.org
Reporter: emaste at freebsd.org
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
At r261576 an lld-linked hello world segfaults at program termination:
% clang -fuse-ld=lld -static hello.c
% ./a.out
Hello, world.
zsh: segmentation fault (core dumped) ./a.out
The the .dtors section in my hello world:
% readelf -S a.out | grep -A1 dtors
[15] .dtors PROGBITS 0000000000074028 00064030
0000000000000018 0000000000000000 WA 0 0 8
% readelf -x .dtors a.out
Hex dump of section '.dtors':
0x00074028 ffffffff ffffffff e0be0600 00000000 ................
0x00074038 00000000 00000000 ........
But when running:
(lldb) memory read --size 8 --format hex 0x74028
0x00074028: 0x0000000000000000 0xffffffffffffffff
0x00074038: 0x000000000006bee0 0x0000000000000000
0x00074048: 0x0000000000000000 0x0000000000000000
0x00074058: 0x0000000000000000 0x0000000000000000
The program & section headers disagree
Nearby section headers:
[10] .init PROGBITS 0000000000073de8 00063de8
0000000000000013 0000000000000000 AX 0 0 4
[11] .fini PROGBITS 0000000000073dfc 00063dfc
000000000000000e 0000000000000000 AX 0 0 4
[12] .tdata PROGBITS 0000000000074000 00064000
0000000000000004 0000000000000000 WAT 0 0 4
[13] .tbss NOBITS 0000000000074010 00064010
0000000000000068 0000000000000000 WAT 0 0 16
[14] .ctors PROGBITS 0000000000074008 00064010
0000000000000020 0000000000000000 WA 0 0 8
[15] .dtors PROGBITS 0000000000074028 00064030
0000000000000018 0000000000000000 WA 0 0 8
[16] .jcr PROGBITS 0000000000074040 00064048
0000000000000008 0000000000000000 WA 0 0 8
[17] .data PROGBITS 0000000000075000 00065000
0000000000003460 0000000000000000 WA 0 0 16
[18] .bss NOBITS 0000000000078460 00068460
000000000001d77d 0000000000000000 WA 0 0 16
% readelf -l a.out.lld
Elf file type is EXEC (Executable file)
Entry point 0x23000
There are 7 program headers, starting at offset 64
Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
PHDR 0x0000000000000040 0x0000000000010040 0x0000000000010040
0x0000000000000188 0x0000000000000188 R 8
LOAD 0x0000000000000000 0x0000000000010000 0x0000000000010000
0x00000000000128a0 0x00000000000128a0 R 1000
LOAD 0x0000000000013000 0x0000000000023000 0x0000000000023000
0x0000000000050e0a 0x0000000000050e0a R E 1000
LOAD 0x0000000000064000 0x0000000000074000 0x0000000000074000
0x0000000000004460 0x0000000000021bdd RW 1000
TLS 0x0000000000064000 0x0000000000074000 0x0000000000074000
0x0000000000000010 0x0000000000000080 R 10
GNU_RELRO 0x0000000000064000 0x0000000000074000 0x0000000000074000
0x0000000000000050 0x0000000000000048 R 1
GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 RW 0
Section to Segment mapping:
Segment Sections...
00
01 .note.tag .rodata .eh_frame .rodata .rodata .rodata .rodata .rodata
02 .text .init .fini
03 .tdata .ctors .dtors .jcr .data .bss
04 .tdata .tbss
05 .ctors .dtors .jcr
06
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160223/a210eb23/attachment.html>
More information about the llvm-bugs
mailing list