From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpcmd0756.aruba.it (smtpcmd0756.aruba.it [62.149.156.56]) by sourceware.org (Postfix) with ESMTP id 609873855030 for ; Mon, 12 Jul 2021 10:32:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 609873855030 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=benettiengineering.com Authentication-Results: sourceware.org; spf=none smtp.mailfrom=benettiengineering.com Received: from ubuntu.localdomain ([146.241.183.1]) by Aruba Outgoing Smtp with ESMTPSA id 2tFAmKJVnzOG12tFBmeJii; Mon, 12 Jul 2021 12:32:58 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=aruba.it; s=a1; t=1626085978; bh=Bc3lbSdBwrTZiPgyfjGETVbpoJgTVBh+BIzH2pLyMhQ=; h=From:To:Subject:Date:MIME-Version; b=AO9sAAe1CDBn0HNd3EtNoYDKnMaZQ2ZFmYoCeCVjqQP5bTzBWpnVw0ZCfHC04doMm 9YmpVNmMl+47XVWeujYyykV6aVwuwuRVEJZK+F7zMD1QWy2Zjtvqk9KqyQoUf5fgYh NiCULBUQr0gKYeY4USyHRjTd9i9G53lSCleN0RaYijsALi802qeGwo/lx+dVhmzd07 Zrj23BRRvTLimFBRt9C9TuiNcuCEz+DGhVc74z9w8tBy0syIAMrFKgIRzjGqDQbkoO e18KPdZPpbsulv8AA02jcc3/1ehi1HVGlZgok1lS+UvZd5DrVCEhVQVrs6s4GMO6w+ pCJzclJEiwfMw== From: Giulio Benetti To: Openrisc Cc: Stafford Horne , Richard Henderson , GNU Binutils , Richard Henderson , Giulio Benetti Subject: [PATCH] or1k: fix pc-relative relocation against dynamic on PC relative 26 bit relocation Date: Mon, 12 Jul 2021 12:32:56 +0200 Message-Id: <20210712103256.2275617-1-giulio.benetti@benettiengineering.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CMAE-Envelope: MS4wfJ5f8PLK4qNLYInU3lX51DbQfJPnGIOeXiI7jzPodRyTjFp1Lmc5dFiv26QpZ5EfpyZP9aNhNzAF2pd2EdFZO5SA6BC7rM7xESAuTSU4BvEGTocj/Kmb EEukvszZq4CgUrArh9G4ynFd3g0lLfm00tdfLC/l5exk34FAEVxAqPIK7hvyx5swmK/zQZQa5SXnJxDO80mbdPLqpWJNpGWLazzhD/5q46gfpSMgp+szHwiP MYXR2nXuXFEPnZKmsugm0o+UtbbQOqTUyvmPJ9q4gH9Bhui9nXGdGz5ad4I3qx3rq7ZT/Sg1EY53TZ3gK3+MexThdombV0aG1TfnAwCm+7eF0gg6ZTuvZxoU 3byukqluTj9vHajnnGyZP6HVRs3yA1shqXpatvkScMY6JxBrSo8= X-Spam-Status: No, score=-8.0 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_STOCKGEN, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Jul 2021 10:33:01 -0000 When building openal we were seeing the assert failure: /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: pc-relative relocation against dynamic symbol alSourcePausev /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: pc-relative relocation against dynamic symbol alSourceStopv /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: pc-relative relocation against dynamic symbol alSourceRewindv /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: pc-relative relocation against dynamic symbol alSourcePlayv collect2: error: ld returned 1 exit status This happens because in R_OR1K_INSN_REL_26 case we can't reference local symbol as previously done but we need to make sure that calls to actual symbol always call the version of current object. bfd/Changelog: * elf32-or1k.c (or1k_elf_relocate_section): use a separate entry in switch case R_OR1K_INSN_REL_26 where we need to check for !SYMBOL_CALLS_LOCAL() instead of !SYMBOL_REFERENCES_LOCAL(). Signed-off-by: Giulio Benetti --- bfd/elf32-or1k.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c index 4ae7f324d33..4f9092539f5 100644 --- a/bfd/elf32-or1k.c +++ b/bfd/elf32-or1k.c @@ -1543,6 +1543,18 @@ or1k_elf_relocate_section (bfd *output_bfd, break; case R_OR1K_INSN_REL_26: + /* For a non-shared link, these will reference plt or call the + version of actual object. */ + if (bfd_link_pic (info) && !SYMBOL_CALLS_LOCAL (info, h)) + { + _bfd_error_handler + (_("%pB: pc-relative relocation against dynamic symbol %s"), + input_bfd, name); + ret_val = false; + bfd_set_error (bfd_error_bad_value); + } + break; + case R_OR1K_PCREL_PG21: case R_OR1K_LO13: case R_OR1K_SLO13: -- 2.25.1