1From 203b80f8dbdd3ddb860114b03351a0dea28c978f Mon Sep 17 00:00:00 2001 2From: Giulio Benetti <giulio.benetti@benettiengineering.com> 3Date: Sat, 10 Jul 2021 17:57:34 +0200 4Subject: [PATCH] or1k: fix pc-relative relocation against dynamic on PC 5 relative 26 bit relocation 6 7When building openal we were seeing the assert failure: 8 9/home/buildroot/autobuild/run/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/or1k-buildroot-linux-uclibc/9.3.0/../../../../or1k-buildroot-linux-uclibc/bin/ld: CMakeFiles/OpenAL.dir/al/source.cpp.o: 10pc-relative relocation against dynamic symbol alSourcePausev 11/home/buildroot/autobuild/run/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/or1k-buildroot-linux-uclibc/9.3.0/../../../../or1k-buildroot-linux-uclibc/bin/ld: CMakeFiles/OpenAL.dir/al/source.cpp.o: 12pc-relative relocation against dynamic symbol alSourceStopv 13/home/buildroot/autobuild/run/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/or1k-buildroot-linux-uclibc/9.3.0/../../../../or1k-buildroot-linux-uclibc/bin/ld: CMakeFiles/OpenAL.dir/al/source.cpp.o: 14pc-relative relocation against dynamic symbol alSourceRewindv 15/home/buildroot/autobuild/run/instance-0/output-1/host/opt/ext-toolchain/bin/../lib/gcc/or1k-buildroot-linux-uclibc/9.3.0/../../../../or1k-buildroot-linux-uclibc/bin/ld: CMakeFiles/OpenAL.dir/al/source.cpp.o: 16pc-relative relocation against dynamic symbol alSourcePlayv 17collect2: error: ld returned 1 exit status 18 19This happens because in R_OR1K_INSN_REL_26 case we can't reference local 20symbol as previously done but we need to make sure that calls to actual 21symbol always call the version of current object. 22 23bfd/Changelog: 24 25 * elf32-or1k.c (or1k_elf_relocate_section): use a separate entry 26 in switch case R_OR1K_INSN_REL_26 where we need to check for 27 !SYMBOL_CALLS_LOCAL() instead of !SYMBOL_REFERENCES_LOCAL(). 28 29Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com> 30--- 31 bfd/elf32-or1k.c | 12 ++++++++++++ 32 1 file changed, 12 insertions(+) 33 34diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c 35index 32063ab0289..67252394173 100644 36--- a/bfd/elf32-or1k.c 37+++ b/bfd/elf32-or1k.c 38@@ -1543,6 +1543,18 @@ or1k_elf_relocate_section (bfd *output_bfd, 39 break; 40 41 case R_OR1K_INSN_REL_26: 42+ /* For a non-shared link, these will reference plt or call the 43+ version of actual object. */ 44+ if (bfd_link_pic (info) && !SYMBOL_CALLS_LOCAL (info, h)) 45+ { 46+ _bfd_error_handler 47+ (_("%pB: pc-relative relocation against dynamic symbol %s"), 48+ input_bfd, name); 49+ ret_val = false; 50+ bfd_set_error (bfd_error_bad_value); 51+ } 52+ break; 53+ 54 case R_OR1K_PCREL_PG21: 55 case R_OR1K_LO13: 56 case R_OR1K_SLO13: 57-- 582.31.1 59 60