https://sourceware.org/bugzilla/show_bug.cgi?id=34336
Bug ID: 34336
Summary: Relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol
`stderr@@GLIBC_2.17'
Product: binutils
Version: 2.45.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: binutils
Assignee: unassigned at sourceware dot org
Reporter: pmikhalicin at rutoken dot ru
Target Milestone: ---
Created attachment 16809
--> https://sourceware.org/bugzilla/attachment.cgi?id=16809&action=edit
patch with fix suggestion
> Components: opcodes
> OS: linux x86_64 (build cross toolchain for arm64)
> Summery
Hi!
I tried to build crosstool-ng toolchain for arm64 and gcc15.
During building binutils I faced with such error:
```
[ALL ] libtool: install: (cd
/builds/rutoken/dev/ci/linux/linux-toolchains/build/.build/aarch64-unknown-linux-gnu/build/build-binutils-for-target/opcodes;
/usr/bin/bash
/builds/rutoken/dev/ci/linux/linux-toolchains/build/.build/aarch64-unknown-linux-gnu/build/build-binutils-for-target/opcodes/libtool
--silent --tag CC --mode=relink aarch64-unknown-linux-gnu-gcc -W -Wall
-Wstrict-prototypes -Wmissing-prototypes -Wshadow -Wstack-usage=262144 -g -O2
-release 2.45 -o libopcodes.la -rpath /usr/lib dis-buf.lo disassemble.lo
dis-init.lo aarch64-asm.lo aarch64-dis.lo aarch64-opc.lo aarch64-asm-2.lo
aarch64-dis-2.lo aarch64-opc-2.lo arm-dis.lo ../bfd/libbfd.la
-L/builds/rutoken/dev/ci/linux/linux-toolchains/build/.build/aarch64-unknown-linux-gnu/build/build-binutils-for-target/opcodes/../libiberty/pic
-liberty -Wl,-lc,--as-needed,-lm,--no-as-needed -inst-prefix-dir
/builds/rutoken/dev/ci/linux/linux-toolchains/toolchains/glibc-arm64-gcc15/aarch64-unknown-linux-gnu/sysroot)
[ALL ]
/opt/x-tools/glibc-arm64-gcc15/lib/gcc/aarch64-unknown-linux-gnu/15.2.0/../../../../aarch64-unknown-linux-gnu/bin/ld:
/opt/x-tools/glibc-arm64-gcc15/aarch64-unknown-linux-gnu/sysroot/usr/lib/libiberty.a(obstack.o)(.text+0x4):
unresolvable R_AARCH64_ADR_PREL_PG_HI21 relocation against symbol
`stderr@@GLIBC_2.17'
[ALL ]
/opt/x-tools/glibc-arm64-gcc15/lib/gcc/aarch64-unknown-linux-gnu/15.2.0/../../../../aarch64-unknown-linux-gnu/bin/ld:
final link failed: bad value
[ERROR] collect2: error: ld returned 1 exit status
[ERROR] libtool: install: error: relink `libopcodes.la' with the above
command before installing it
```
I tried to figure out what leads to this problem and noticed that, we tried to
link `.../opcodes/../libiberty/pic/libiberty.a`, but
`.../sysroot/usr/lib/libiberty.a` was linked instead.
It happens because libtool founds libbfd firstly and passes it's pathes to
linker before libiberty pathes. (-L/path/to/bfd/dirs -lbfd -L/path/to/libiberty
-liberty)
As I got, libbfd libraries should be located at install root. Install root
could contains some other libraries searched during linkage (like libiberty).
So, it's better to pass libbfd library at the end of args of libtool
So, I suggest a patch, which should put libbdf linkage flags at the end of arg
list (-L/path/to/libiberty -liberty -L/path/to/bfd/dirs -lbfd)
--
You are receiving this mail because:
You are on the CC list for the bug.