This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] gold: Don't adjust local symbol values in relocatable link twice


On Mon, Nov 27, 2017 at 5:39 PM, Cary Coutant <ccoutant@gmail.com> wrote:
>> This patch has broken -r for all REL targets, including i386.
>
> The fix for PR 19291 broke some other cases where -r is used with scripts,
> as reported in PR 22266. The original fix for PR 22266 ended up breaking
> many cases for REL targets, where the addends are stored in the section data,
> and are not being adjusted properly.
>
> The problem was basically that in a relocatable output file (ET_REL),
> symbol values are supposed to be relative to the start address of their
> section. Usually in a relocatable file, all sections start at 0, so the
> failure to get this right is often irrelevant, but with a linker script,
> we occasionally see an output section whose starting address is not 0,
> and gold would occasionally write a symbol with its relocated value instead
> of its section-relative value.
>
> This patch reverts the recent fix for PR 22266 as well as my original fix
> for PR 19291. The original fix moved the symbol value adjustment to
> write_local_symbols, but neglected to undo a few places where the adjustment
> was also being applied, resulting in an occasional double adjustment. The
> more recent fix removed those other adjustments, but then failed to
> re-account for the adjustment when rewriting the relocations on REL targets.
>
> With the old attempts reverted, we now apply the symbol value adjustment to
> the one case that had been missed (non-section symbols in merge sections).
> But now we also need to account for the adjustment when rewriting the addends
> for RELA relocations.
>
> Tested on x86_64 and i386.
>
> Heads up, Alan! I copied the change to relocate_relocs() from
> target-reloc.h into the PPC version of the routine. You may want to
> double-check my work and run the tests natively.
>
> -cary
>
>
> 2017-11-27  Cary Coutant  <ccoutant@gmail.com>
>
> gold/
>         PR gold/19291
>         PR gold/22266
>         * object.cc (Sized_relobj_file::compute_final_local_value_internal):
>         Revert changes from 2017-11-08 patch.  Adjust symbol value in
>         relocatable links for non-section symbols.
>         (Sized_relobj_file::compute_final_local_value): Revert changes from
>         2017-11-08 patch.
>         (Sized_relobj_file::do_finalize_local_symbols): Likewise.
>         (Sized_relobj_file::write_local_symbols): Revert changes from
>         2015-11-25 patch.
>         * object.h (Sized_relobj_file::compute_final_local_value_internal):
>         Revert changes from 2017-11-08 patch.
>         * powerpc.cc (Target_powerpc::relocate_relocs): Adjust addend for
>         relocatable links.
>         * target-reloc.h (relocate_relocs): Adjust addend for relocatable links.
>         * testsuite/pr22266_a.c (hello): New function.
>         * testsuite/pr22266_main.c (main): Add test for merge sections.
>         * testsuite/pr22266_script.t: Add rule for .rodata.

I am checking in this patch to fix the build with GCC 4.2.

-- 
H.J.
From ff174d3ffad13af17a61583db3e1cd9c0c6cf237 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Tue, 28 Nov 2017 09:00:44 -0800
Subject: [PATCH] gold: Add a newline at end of pr22266_a.c

This patch fixes the build with GCC 4.2:

gold/testsuite/pr22266_a.c:13:2: error: no newline at end of file

	* testsuite/pr22266_a.c: Add a newline at end of file.
---
 gold/ChangeLog             | 4 ++++
 gold/testsuite/pr22266_a.c | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/gold/ChangeLog b/gold/ChangeLog
index c3c7481ed7..4cf92baa5a 100644
--- a/gold/ChangeLog
+++ b/gold/ChangeLog
@@ -1,3 +1,7 @@
+2017-11-28  H.J. Lu  <hongjiu.lu@intel.com>
+
+	* testsuite/pr22266_a.c: Add a newline at end of file.
+
 2017-11-27  Cary Coutant  <ccoutant@gmail.com>
 
 	PR gold/19291
diff --git a/gold/testsuite/pr22266_a.c b/gold/testsuite/pr22266_a.c
index bdc09d4416..7c773db546 100644
--- a/gold/testsuite/pr22266_a.c
+++ b/gold/testsuite/pr22266_a.c
@@ -10,4 +10,4 @@ const char *
 hello (void)
 {
   return "XXXHello, world!" + 3;
-}
\ No newline at end of file
+}
-- 
2.14.3


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]