strip producing invalid executable

H.J. Lu hjl.tools@gmail.com
Sun Sep 14 22:33:16 GMT 2025


On Sun, Sep 14, 2025 at 3:02 PM Paul Edwards <mutazilah@gmail.com> wrote:

> I produce 32-bit x86 ELF executables, with relocations, using pdld.
>
> They run fine.
>
>
> But when I attempt to strip them (noting that "file" claims
> they are already stripped), strip silently produces a broken
> executable.
>
>
> root@kerravon2-pc:/home/kerravon/w2kshare# ./pdptest.orig
> welcome to pdptest
> main function is at 004011F4
> allocating 10 bytes
> m1 is EA192004
> allocating 20 bytes
> m2 is EA191004
> stack is around FFA44934
> usage: pdptest [-bb/-tt/-tb/-bt] <infile> <outfile>
> default is text to text copy
>
> root@kerravon2-pc:/home/kerravon/w2kshare# ./pdptest.strip
> Segmentation fault (core dumped)
> root@kerravon2-pc:/home/kerravon/w2kshare#
>
>
> root@kerravon2-pc:/home/kerravon/w2kshare# ls -l pdptest.orig
> -rwxrwx--- 1 root vboxsf 39480 Sep 14 18:27 pdptest.orig
> root@kerravon2-pc:/home/kerravon/w2kshare# ls -l pdptest.strip
> -rwxrwx--- 1 root vboxsf 39340 Sep 14 18:28 pdptest.strip
> root@kerravon2-pc:/home/kerravon/w2kshare# file pdptest.orig
> pdptest.orig: ELF 32-bit LSB executable, Intel 80386, version 1
> (SYSV), statically linked, stripped
> root@kerravon2-pc:/home/kerravon/w2kshare#
>
>
> If anyone is interested, I have uploaded those two files as:
>
> https://pdos.org/stripbug.zip


The section header is wrong:

 Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk
Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0
0  0
  [ 1] .text             PROGBITS        00401000 001000 0062ea 00   X  0
0 4096
  [ 2] .rel.text         REL             00000000 0072ec 001088 08      0
1  4
  [ 3] .data             PROGBITS        00408000 009000 0007f0 00   W  0
0 4096
  [ 4] .rel.data         REL             00000000 0097f0 000080 08      0
3  4
  [ 5] .bss              NOBITS          00409000 000000 006bb0 00  WA  0
0 4096
  [ 6] .shstrtab         STRTAB          00000000 009870 000024 00      0
0  1

The SHF_ALLOC bit is unset on  .text  and .data sections.


>
> (noting that it may be a pdld bug that is undetectable by
> strip, so not a strip bug as the name suggests).
>
>
> I assume there haven't been massive changes to strip since:
>
> root@kerravon2-pc:/home/kerravon/w2kshare# strip --version
> GNU strip (GNU Binutils for Ubuntu) 2.38
>
>
> Thanks. Paul.
>


-- 
H.J.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://sourceware.org/pipermail/binutils/attachments/20250914/18320024/attachment.htm>


More information about the Binutils mailing list