This is the mail archive of the 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]

[PATCH] gold: fix merging of non-section symbols

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 <>
 gold/ | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/gold/ b/gold/
index a631c99..be7cda9 100644
--- a/gold/
+++ b/gold/
@@ -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.
-		  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))

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