Hello,
While compiling the Xen kernel on FreeBSD I've realized that (at least on FreeBSD) using elfcopy --rename-section produces output object files that SIGSEGV GNU ld (tried versions 2.17.50 and 2.25.1). The issue is quite simple to reproduce, here are the steps:
$ cat main.c int main(int argc, char *argv[]) { return 0; } $ clang -g -c main.c $ elfcopy --rename-section .comment=.init.comment main.o main.init.o $ ld -melf_x86_64_fbsd -r -o main.ld.o main.init.o Segmentation fault (core dumped)
If GNU objcopy is used instead of elfcopy everything works, and ld doesn't SIGSEGV. I also have a trace of the SIGSEGV in ld, in case it's helpful:
Starting program: /usr/bin/ld -melf_x86_64_fbsd -r -o main.ld.o main.init.o warning: shared library handler failed to enable breakpoint Program received signal SIGSEGV, Segmentation fault. 0x000000000042d0f4 in _bfd_elf_rela_local_sym () (gdb) bt #0 0x000000000042d0f4 in _bfd_elf_rela_local_sym () #1 0x0000000000460d70 in elf64_x86_64_relocate_section () #2 0x00000000004396be in bfd_elf_final_link () #3 0x000000000041a3be in ldwrite () at /root/freebsd-dis/gnu/usr.bin/binutils/ld/../../../../contrib/binutils/ld/ldwrite.c:557 #4 0x00000000004179b8 in main (argc=<value optimized out>, argv=<value optimized out>) at /root/freebsd-dis/gnu/usr.bin/binutils/ld/../../../../contrib/binutils/ld/ldmain.c:468 #5 0x000000000040031f in _start () #6 0x0000000000000000 in ?? () (gdb)
I'm happy to help in anyway I can.
Thanks, Roger.
Attaching my main.o object file, since this issue also seems to be related to the usage of clang 3.8.0.
Confirmed, I tested on stable/10 (with clang 3.4.1) and it did not trigger the ld segfault.
Thanks for reporting this issue. I'll handle it.
Simpler reproduction:
Should be fixed by [r3443]. Please verify.
Related
Commit: [r3443]
The ld segfault is indeed fixed.
Thanks, I can confirm the issue is also solved on my side :).
Issue fixed.