bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/27271] New: c6x-unknown-uclinux-ld segfaults linking ld-uClibc-1


From: mikpelinux at gmail dot com
Subject: [Bug ld/27271] New: c6x-unknown-uclinux-ld segfaults linking ld-uClibc-1.0.37.so
Date: Thu, 28 Jan 2021 18:19:13 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=27271

            Bug ID: 27271
           Summary: c6x-unknown-uclinux-ld segfaults linking
                    ld-uClibc-1.0.37.so
           Product: binutils
           Version: 2.37 (HEAD)
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: mikpelinux at gmail dot com
  Target Milestone: ---

Created attachment 13170
  --> https://sourceware.org/bugzilla/attachment.cgi?id=13170&action=edit
ld-uClibc_so.a

Attempting to build a cross toolchain for c6x-unknown-uclinux with
binutils-2.36 or binutils head fails due to ld segfaulting when linking
ld-uClibc-1.0.37.so:

c6x-unknown-uclinux-gcc  -Wl,-EB -funsigned-char -fno-builtin -fcommon -fno-asm
-fmerge-all-constants -std=gnu99 -mbig-endian -shared -Wl,--warn-common
-Wl,--warn-once -Wl,-z,combreloc -Wl,-z,relro -Wl,-O2 -Wl,-z,defs -Wl,-s 
-Wl,-e,_start -Wl,-z,now -Wl,-Bsymbolic -Wl,--export-dynamic -Wl,--sort-common
-Wl,--no-undefined -Wl,--discard-locals -Wl,--discard-all -Wl,--dsbt-index=1
-Wl,-soname=ld-uClibc.so.1 -nostdlib -nostartfiles -o lib/ld-uClibc-1.0.37.so 
-Wl,--whole-archive ldso/ldso/ld-uClibc_so.a -Wl,--no-whole-archive 
/mnt/scratch/cross/cross-c6x/lib/gcc/c6x-unknown-uclinux/10.2.0/be/libgcc.a  
/mnt/scratch/cross/cross-c6x/lib/gcc/c6x-unknown-uclinux/10.2.0/../../../../c6x-unknown-uclinux/bin/ld:
warning: -z relro ignored
collect2: fatal error: ld terminated with signal 11 [Segmentation fault], core
dumped
compilation terminated.
make: *** [ldso/ldso/Makefile.in:88: lib/ld-uClibc.so] Error 1

This works fine with binutils-2.35.1. A git bisect identified:

# first bad commit: [c8bad65eee4667f731c4abcc4642c4a68c8601ca]
is_relocatable_executable --exclude-libs failure

That commit added several unchecked pointer dereferences. After some
experimentation I found that the following prevented the segfault:

--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -537,6 +537,7 @@ bfd_elf_link_record_dynamic_symbol (struct bfd_link_info
*info,
              if (!elf_hash_table (info)->is_relocatable_executable
                  || ((h->root.type == bfd_link_hash_defined
                       || h->root.type == bfd_link_hash_defweak)
+                     && h->root.u.def.section->owner != NULL
                      && h->root.u.def.section->owner->no_export)
                  || (h->root.type == bfd_link_hash_common
                      && h->root.u.c.p->section->owner->no_export))

I'm not suggesting this is the correct fix, but it indicates that the c6x ld
fails to set up h->root.u.def.section->owner correctly.

Repeat-by (if you're not familiar with building uClibc-ng):
1. Download the (to be) attached ld-uClibc_so.a and libgcc.a to e.g. /tmp/
2. Enter binutils-gdb.git, ./configure --target=c6x-unknown-uclinux, make.
3. ld/ld-new --eh-frame-hdr -EB -shared -o lib/ld-uClibc-1.0.37.so
--warn-common --warn-once -z combreloc -z relro -O2 -z defs -s -e _start -z now
-Bsymbolic --export-dynamic --sort-common --no-undefined --discard-locals
--discard-all --dsbt-index=1 -soname=ld-uClibc.so.1 --whole-archive
/tmp/ld-uClibc_so.a --no-whole-archive /tmp/libgcc.a

Host: Fedora 32 / x86_64
Toolchain components: binutils-2.36.tar.xz (or git), linux-5.10.tar.xz,
gcc-10.2.0.tar.xz, uClibc-ng-1.0.37.tar.xz (all unmodified upstream tarballs).

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]