This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] gold: fix merging of non-section symbols
- From: Xiao Jia <xiaoj at google dot com>
- To: binutils at sourceware dot org
- Cc: Xiao Jia <xiaoj at google dot com>
- Date: Wed, 2 Mar 2016 13:45:03 -0800
- Subject: [PATCH] gold: fix merging of non-section symbols
- Authentication-results: sourceware.org; auth=none
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