Repository: davidlattimore/wild (rust)

Issue:
Incorrect string-merge results -mcmodel=large is used with clang
When `program_name_29___cpp_integration_cc__` is compiled with `clang` rather than `gcc`, it fails. Apparently all the merged strings end up as the string `ELF`. See https://github.com/davidlattimore/wild/pull/140. We should probably first add an option to allow overriding the compiler - i.e. #179.

Pull request description:
Fix merged-string SymRelGotBase references
Fixes #180

Patch:
diff --git a/libwild/src/elf_writer.rs b/libwild/src/elf_writer.rs
index a3d3d2d..8f341f6 100644
--- a/libwild/src/elf_writer.rs
+++ b/libwild/src/elf_writer.rs
@@ -1917,7 +1917,13 @@ fn apply_relocation<S: StorageModel, A: Arch>(
             .bitand(mask.got_entry)
             .wrapping_add(addend as u64),
         RelocationKind::SymRelGotBase => resolution
-            .value()
+            .value_with_addend(
+                addend,
+                symbol_index,
+                object_layout,
+                &layout.merged_strings,
+                &layout.merged_string_start_addresses,
+            )?
             .bitand(mask.symbol_plus_addend)
             .wrapping_sub(layout.got_base().bitand(mask.got)),
         RelocationKind::PltRelGotBase => resolution
diff --git a/linker-diff/src/lib.rs b/linker-diff/src/lib.rs
index 60ba4a4..8256a19 100644
--- a/linker-diff/src/lib.rs
+++ b/linker-diff/src/lib.rs
@@ -158,6 +158,8 @@ impl Config {
                 "section.bss.alignment",
                 "section.gnu.build.attributes",
                 "section.annobin.notes.entsize",
+                // We don't yet group .lrodata sections separately.
+                "section.lrodata",
                 // We currently output version info when linking against the interpreter
                 // (ld-linux-x86-64.so.2). GNU ld doesn't.
                 ".dynamic.DT_VERNEEDNUM",


Test patch:
diff --git a/wild/tests/sources/cpp-integration.cc b/wild/tests/sources/cpp-integration.cc
index 680895f..0be29c9 100644
--- a/wild/tests/sources/cpp-integration.cc
+++ b/wild/tests/sources/cpp-integration.cc
@@ -25,10 +25,16 @@
 //#CompArgs:-mcmodel=large
 //#LinkArgs:--cc=g++ -Wl,-z,now
 //#EnableLinker:lld
-//#Cross:false
 // TODO: Ubuntu: cc1plus: sorry, unimplemented: code model 'large' with '-fPIC'
 //#Arch: x86_64
 
+//#Config:clang-model-large:default
+//#Compiler:clang
+//#CompArgs:-mcmodel=large
+//#LinkArgs:--cc=clang++ -Wl,-z,now
+//#EnableLinker:lld
+//#Arch: x86_64
+
 #include <iostream>
 #include <string>