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

            Bug ID: 33263
           Summary: Assertion failure when linking AArch64 code with
                    -Bsymbolic
           Product: binutils
           Version: 2.44
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: kartatz at amanoteam dot com
  Target Milestone: ---

Created attachment 16236
  --> https://sourceware.org/bugzilla/attachment.cgi?id=16236&action=edit
compiled object and generated assembly files for hwasan_dynamic_shadow.cpp

I'm trying to build a GCC cross-compiler targeting Android AArch64. Currently,
BFD is able to link almost all target libraries, with the exception of hwasan
(from libsanitizer), which fails with the following output:

```
libtool: link:  /tmp/gcc-releases-gcc-15/build/./gcc/xgcc -shared-libgcc <...> 
-fPIC -DPIC -shared -nostdlib <...> .libs/hwasan_dynamic_shadow.o <...>
-Wl,-soname -Wl,libhwasan.so -o .libs/libhwasan.so
/tmp/pino/aarch64-unknown-linux-android/bin/ld.bfd: BFD (GNU Binutils) 2.44
assertion fail ../../bfd/elfnn-aarch64.c:10072
collect2: error: ld returned 1 exit status
make[4]: *** [Makefile:564: libhwasan.la] Error 1
```

I then tracked the assertion failure to this specific hwasan_dynamic_shadow.o
object file:

```
$ aarch64-unknown-linux-android-ld -shared -Bsymbolic ./hwasan_dynamic_shadow.o 
aarch64-unknown-linux-android-ld: BFD (GNU Binutils) 2.44 assertion fail
../../bfd/elfnn-aarch64.c:10072
```

After some testing, I found that compiling the GCC libraries with -fno-plt
makes the assertion failure trigger more often. Specifically, it leads to the
same assertion failure when linking libatomic and also now triggers a "double
free or corruption" error from glibc:

```
libtool: link:  /tmp/gcc-releases-gcc-15/build/./gcc/xgcc -shared-libgcc <...> 
-fPIC -DPIC -shared -nostdlib <...> .libs/hwasan_dynamic_shadow.o <...>
-fno-plt -Wl,-soname -Wl,libhwasan.so -o .libs/libhwasan.so
/tmp/pino/aarch64-unknown-linux-android/bin/ld.bfd: BFD (GNU Binutils) 2.44
assertion fail ../../bfd/elfnn-aarch64.c:10072
double free or corruption (!prev)
collect2: fatal error: ld terminated with signal 6 [Aborted], core dumped
compilation terminated.
```

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

Reply via email to