Noticed while testing with LLVM 15, but it affects plain -current
as well. If I take a binary that was linked with ld.bfd and strip it
(i.e. this is now using llvm-strip), it breaks the output file in
such a way that it cannot be executed:

: i386.p; cat a.c
#include <stdio.h>
int main() {
        printf("test\n");
}
: i386.p; make a LDFLAGS=-fuse-ld=/usr/bin/ld.bfd
cc -O2 -pipe   -fuse-ld=/usr/bin/ld.bfd -o a a.c
: i386.p; strip -o a.stripped a
: i386.p; ./a
test
: i386.p; ./a.stripped
Abort trap

Seems that the SIGABRT is from kern_exec's sys_execve ->
exec_process_vmcmds() failing.

Binaries from the above available at

https://junkpile.org/a
https://junkpile.org/a.stripped

Does anyone have an idea what might be wrong please?

(The reason why the machine is even doing this in the first place
is that ports/lang/gcc isn't building on i386 with llvm 15 and
ld.lld, which is another story. Still, it seems suboptimal the
llvm-strip is breaking this binary. For now I'm using unstripped
ld.bfd-generated gcc binaries to workaround these two issues).

: i386.p; readelf -S a
There are 26 section headers, starting at offset 0x20d0:

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] .init             PROGBITS        00000220 000220 00000d 00  AX  0   0 16
  [ 2] .plt              PROGBITS        00000230 000230 000060 04  AX  0   0  4
  [ 3] .text             PROGBITS        00000290 000290 0002e8 00  AX  0   0 16
  [ 4] .fini             PROGBITS        00000580 000580 00000d 00  AX  0   0 16
  [ 5] .interp           PROGBITS        20000000 001000 000013 00   A  0   0  1
  [ 6] .note.openbsd.ide NOTE            20000014 001014 000018 00   A  0   0  4
  [ 7] .hash             HASH            2000002c 00102c 000070 04   A  9   0  4
  [ 8] .gnu.hash         GNU_HASH        2000009c 00109c 000034 04   A  9   0  4
  [ 9] .dynsym           DYNSYM          200000d0 0010d0 000170 10   A 10  13  4
  [10] .dynstr           STRTAB          20000240 001240 000066 00   A  0   0  1
  [11] .rel.dyn          REL             200002a8 0012a8 000010 08   A  9   0  4
  [12] .rel.plt          REL             200002b8 0012b8 000028 08   A  9   2  4
  [13] .rodata           PROGBITS        200002e0 0012e0 000005 01 AMS  0   0  1
  [14] .eh_frame_hdr     PROGBITS        200002e8 0012e8 000034 00   A  0   0  4
  [15] .eh_frame         PROGBITS        2000031c 00131c 0000cc 00   A  0   0  4
  [16] .openbsd.randomda PROGBITS        20001f18 001f18 000004 00  WA  0   0  4
  [17] .jcr              PROGBITS        20001f1c 001f1c 000004 00  WA  0   0  4
  [18] .dynamic          DYNAMIC         20001f20 001f20 0000a8 08  WA 10   0  4
  [19] .ctors            PROGBITS        20001fc8 001fc8 000008 00  WA  0   0  4
  [20] .dtors            PROGBITS        20001fd0 001fd0 000008 00  WA  0   0  4
  [21] .got              PROGBITS        20001fd8 001fd8 000028 04  WA  0   0  4
  [22] .bss              NOBITS          20002000 002000 000030 00  WA  0   0  4
  [23] .shstrtab         STRTAB          00000000 002000 0000cf 00      0   0  1
  [24] .symtab           SYMTAB          00000000 0024e0 000350 10     25  35  4
  [25] .strtab           STRTAB          00000000 002830 000153 00      0   0  1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings)
  I (info), L (link order), G (group), x (unknown)
  O (extra OS processing required) o (OS specific), p (processor specific)
: i386.p; readelf -S a.stripped
There are 24 section headers, starting at offset 0x10c0:

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] .init             PROGBITS        00000220 000220 00000d 00  AX  0   0 16
  [ 2] .plt              PROGBITS        00000230 000230 000060 04  AX  0   0  4
  [ 3] .text             PROGBITS        00000290 000290 0002e8 00  AX  0   0 16
  [ 4] .fini             PROGBITS        00000580 000580 00000d 00  AX  0   0 16
  [ 5] .interp           PROGBITS        20000000 00058d 000013 00   A  0   0  1
  [ 6] .note.openbsd.ide NOTE            20000014 0005a1 000018 00   A  0   0  4
  [ 7] .hash             HASH            2000002c 0005b9 000070 04   A  9   0  4
  [ 8] .gnu.hash         GNU_HASH        2000009c 000629 000034 04   A  9   0  4
  [ 9] .dynsym           DYNSYM          200000d0 00065d 000170 10   A 10  13  4
  [10] .dynstr           STRTAB          20000240 0007cd 000066 00   A  0   0  1
  [11] .rel.dyn          REL             200002a8 000835 000010 08   A  9   0  4
  [12] .rel.plt          REL             200002b8 000845 000028 08   A  9   2  4
  [13] .rodata           PROGBITS        200002e0 00086d 000005 01 AMS  0   0  1
  [14] .eh_frame_hdr     PROGBITS        200002e8 000875 000034 00   A  0   0  4
  [15] .eh_frame         PROGBITS        2000031c 0008a9 0000cc 00   A  0   0  4
  [16] .openbsd.randomda PROGBITS        20001f18 000f18 000004 00  WA  0   0  4
  [17] .jcr              PROGBITS        20001f1c 000f1c 000004 00  WA  0   0  4
  [18] .dynamic          DYNAMIC         20001f20 000f20 0000a8 08  WA 10   0  4
  [19] .ctors            PROGBITS        20001fc8 000fc8 000008 00  WA  0   0  4
  [20] .dtors            PROGBITS        20001fd0 000fd0 000008 00  WA  0   0  4
  [21] .got              PROGBITS        20001fd8 000fd8 000028 04  WA  0   0  4
  [22] .bss              NOBITS          20002000 001000 000030 00  WA  0   0  4
  [23] .shstrtab         STRTAB          00000000 001000 0000bf 00      0   0  1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings)
  I (info), L (link order), G (group), x (unknown)
  O (extra OS processing required) o (OS specific), p (processor specific)

Reply via email to