* [PATCH] gold: fix merging of non-section symbols
@ 2016-03-02 21:46 Xiao Jia
2016-03-03 19:30 ` Cary Coutant
0 siblings, 1 reply; 4+ messages in thread
From: Xiao Jia @ 2016-03-02 21:46 UTC (permalink / raw)
To: binutils; +Cc: Xiao Jia
os->output_address() returns a virtual address, while what we actually
want is an offset starting from the section.
Without this fix, programs linked with user-provided linker scripts may
segfault e.g. when trying to access string literals. The linker script
that I was using to trigger the segfault was in a non-upstream Linux
kernel tree. It uses RO_DATA_SECTION, which has merge sections such as
".rodata : { *(.rodata) *(.rodata.*) }", and strings in .rodata.* were
incorrectly relocated.
Signed-off-by: Xiao Jia <xiaoj@google.com>
---
gold/object.cc | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/gold/object.cc b/gold/object.cc
index a631c99..be7cda9 100644
--- a/gold/object.cc
+++ b/gold/object.cc
@@ -2405,7 +2405,8 @@ Sized_relobj_file<size, big_endian>::compute_final_local_value_internal(
// This is not a section symbol. We can determine
// the final value now.
lv_out->set_output_value(
- os->output_address(this, shndx, lv_in->input_value()));
+ os->output_address(this, shndx, lv_in->input_value())
+ - os->address());
}
else if (!os->find_starting_output_address(this, shndx, &start))
{
--
2.7.0.rc3.207.g0ac5344
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] gold: fix merging of non-section symbols
2016-03-02 21:46 [PATCH] gold: fix merging of non-section symbols Xiao Jia
@ 2016-03-03 19:30 ` Cary Coutant
2016-03-21 22:34 ` Xiao Jia
0 siblings, 1 reply; 4+ messages in thread
From: Cary Coutant @ 2016-03-03 19:30 UTC (permalink / raw)
To: Xiao Jia; +Cc: Binutils
Is there a PR for this bug?
> os->output_address() returns a virtual address, while what we actually
> want is an offset starting from the section.
I don't think that's right, unless we're doing a relocatable link. See
the use of relocatable_link_adjustment in the "else if" block
immediately following this one.
-cary
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] gold: fix merging of non-section symbols
2016-03-03 19:30 ` Cary Coutant
@ 2016-03-21 22:34 ` Xiao Jia
2016-03-22 1:29 ` Cary Coutant
0 siblings, 1 reply; 4+ messages in thread
From: Xiao Jia @ 2016-03-21 22:34 UTC (permalink / raw)
To: Cary Coutant; +Cc: Binutils
Sorry for the late reply, I spent time on something else.
On Thu, Mar 3, 2016 at 11:30 AM, Cary Coutant <ccoutant@gmail.com> wrote:
> Is there a PR for this bug?
I'm not familiar with the workflow. What is a PR?
>
>> os->output_address() returns a virtual address, while what we actually
>> want is an offset starting from the section.
>
> I don't think that's right, unless we're doing a relocatable link. See
> the use of relocatable_link_adjustment in the "else if" block
> immediately following this one.
Yes in my case it's a relocatable symbol IIRC. I'll take a look at
the code you mentioned. Thanks!
Xiao
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] gold: fix merging of non-section symbols
2016-03-21 22:34 ` Xiao Jia
@ 2016-03-22 1:29 ` Cary Coutant
0 siblings, 0 replies; 4+ messages in thread
From: Cary Coutant @ 2016-03-22 1:29 UTC (permalink / raw)
To: Xiao Jia; +Cc: Binutils
>> Is there a PR for this bug?
>
> I'm not familiar with the workflow. What is a PR?
PR is short for Problem Report. Bugs should be filed in bugzilla, the
binutils bug-tracking database:
https://sourceware.org/bugzilla/
-cary
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-03-22 1:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-02 21:46 [PATCH] gold: fix merging of non-section symbols Xiao Jia
2016-03-03 19:30 ` Cary Coutant
2016-03-21 22:34 ` Xiao Jia
2016-03-22 1:29 ` Cary Coutant
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).