Skip to content

Commit bc0d84b

Browse files
committed
test/link/elf: add merge strings test for -r mode
1 parent 342235e commit bc0d84b

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

test/link/elf.zig

+27
Original file line numberDiff line numberDiff line change
@@ -2649,6 +2649,33 @@ fn testRelocatableEhFrame(b: *Build, opts: Options) *Step {
26492649
return test_step;
26502650
}
26512651

2652+
// Adapted from https://github.com/rui314/mold/blob/main/test/elf/relocatable-mergeable-sections.sh
2653+
fn testRelocatableMergeStrings(b: *Build, opts: Options) *Step {
2654+
const test_step = addTestStep(b, "relocatable-merge-strings", opts);
2655+
2656+
const obj1 = addObject(b, opts, .{ .name = "a", .asm_source_bytes =
2657+
\\.section .rodata.str1.1,"aMS",@progbits,1
2658+
\\val1:
2659+
\\.ascii "Hello \0"
2660+
\\.section .rodata.str1.1,"aMS",@progbits,1
2661+
\\val5:
2662+
\\.ascii "World \0"
2663+
\\.section .rodata.str1.1,"aMS",@progbits,1
2664+
\\val7:
2665+
\\.ascii "Hello \0"
2666+
});
2667+
2668+
const obj2 = addObject(b, opts, .{ .name = "b" });
2669+
obj2.addObject(obj1);
2670+
2671+
const check = obj2.checkObject();
2672+
check.dumpSection(".rodata.str1.1");
2673+
check.checkExact("Hello \x00World \x00");
2674+
test_step.dependOn(&check.step);
2675+
2676+
return test_step;
2677+
}
2678+
26522679
fn testRelocatableNoEhFrame(b: *Build, opts: Options) *Step {
26532680
const test_step = addTestStep(b, "relocatable-no-eh-frame", opts);
26542681

0 commit comments

Comments
 (0)