Bug 24015 - glibc-2.28 on little-endian mips32 broken due to commit 2bf2bf23da
Summary: glibc-2.28 on little-endian mips32 broken due to commit 2bf2bf23da
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.32
: P2 normal
Target Milestone: ---
Assignee: Alan Modra
Depends on:
Reported: 2018-12-20 20:54 UTC by Manuel Lauss
Modified: 2018-12-28 09:56 UTC (History)
0 users

See Also:
Last reconfirmed: 2018-12-27 00:00:00

archive of working and broken libraries (93.89 KB, application/x-bzip)
2018-12-20 20:54 UTC, Manuel Lauss

Note You need to log in before you can comment on or make changes to this bug.
Description Manuel Lauss 2018-12-20 20:54:08 UTC
Created attachment 11480 [details]
archive of working and broken libraries

On MIPS32 little-endian softfloat target ("mipsel-softfloat-linux-gnu"), commit 2bf2bf23da5237f465fdbb759657aeb7825a08a3 ("ELF ld -r scripts") creates a corrupt MIPS32 ld.so binary (glibc-2.28), which segfaults somehere in dl_main().
I see however no issues in other packages.

I attach a tar archive with a working and broken ld-2.28.so file.  The good one was built with binutils commit 	8bca297856, the broken one with 2bf2bf23da.
They seem to differ in only 2 bytes:

# cmp -b -l ld-2.28.so.GOOD ld-2.28.so.BAD 
154657   0 ^@    34 ^\
154661   0 ^@     2 ^B

Please take a look!

Comment 1 Alan Modra 2018-12-23 08:02:19 UTC
The differences are in .sbss, which is oddly made PROGBITS rather than NOBITS.

ld-2.28.so.BAD:     file format elf32-tradlittlemips

Contents of section .sbss:
 35c20 1c000000 02000000                    ........        

ld-2.28.so.GOOD:     file format elf32-tradlittlemips

Contents of section .sbss:
 35c20 00000000 00000000                    ........
Comment 2 cvs-commit@gcc.gnu.org 2018-12-28 04:34:11 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:


commit 0e41bebb938dbe9eae7063f5321429194bfc5ab7
Author: Alan Modra <amodra@gmail.com>
Date:   Fri Dec 28 09:41:44 2018 +1030

    PR24015, glibc-2.28 on little-endian mips32 broken
    Commit 2bf2bf23da exposed a bug on targets that create common sections
    other than the standard ELF SHN_COMMON.  If these are output by ld -r,
    then their type becomes SHT_PROGBITS unless the target handles them
    specially (eg. by elf_backend_special_sections), and if they are
    merged into .bss/.sbss by ld -r then that section becomes SHT_PROGBITS.
    Worse, if they are output by ld -r, then their size is increased by
    bfd_generic_define_common_symbol during final link, which leads to
    bogus file contents being copied to output.
    For mips, it seems to me that the .scommon section should not be
    output for ld -r, but I haven't made that change in this patch.
    	PR 24015
    	* elf.c (bfd_elf_get_default_section_type): Make common sections
    	* linker.c (bfd_generic_define_common_symbol): Clear
Comment 3 Alan Modra 2018-12-28 05:13:18 UTC
Should now be fixed.
Comment 4 Manuel Lauss 2018-12-28 09:56:19 UTC
Thanks, yes it's fixed now.  Final binary is even 8 bytes smaller now.