| ... | ... | @@ -42,6 +42,7 @@ pub fn build(b: *Build) void { |
| 42 | 42 | |
| 43 | 43 | elf_step.dependOn(testDsoPlt(b, .{ .target = glibc_target, .dynamic_linker = dynamic_linker })); |
| 44 | 44 | elf_step.dependOn(testDsoUndef(b, .{ .target = glibc_target, .dynamic_linker = dynamic_linker })); |
| 45 | elf_step.dependOn(testLargeAlignmentDso(b, .{ .target = glibc_target, .dynamic_linker = dynamic_linker })); |
| 45 | 46 | } |
| 46 | 47 | |
| 47 | 48 | fn testCommonSymbols(b: *Build, opts: Options) *Step { |
| ... | ... | @@ -325,6 +326,53 @@ fn testGcSections(b: *Build, opts: Options) *Step { |
| 325 | 326 | return test_step; |
| 326 | 327 | } |
| 327 | 328 | |
| 329 | fn testLargeAlignmentDso(b: *Build, opts: Options) *Step { |
| 330 | const test_step = addTestStep(b, "large-alignment-dso", opts); |
| 331 | |
| 332 | const dso = addSharedLibrary(b, opts); |
| 333 | addCSourceBytes(dso, |
| 334 | \\#include <stdio.h> |
| 335 | \\#include <stdint.h> |
| 336 | \\void hello() __attribute__((aligned(32768), section(".hello"))); |
| 337 | \\void world() __attribute__((aligned(32768), section(".world"))); |
| 338 | \\void hello() { |
| 339 | \\ printf("Hello"); |
| 340 | \\} |
| 341 | \\void world() { |
| 342 | \\ printf(" world"); |
| 343 | \\} |
| 344 | \\void greet() { |
| 345 | \\ hello(); |
| 346 | \\ world(); |
| 347 | \\} |
| 348 | , &.{"-fPIC"}); |
| 349 | dso.link_function_sections = true; |
| 350 | dso.is_linking_libc = true; |
| 351 | |
| 352 | const check = dso.checkObject(); |
| 353 | check.checkInSymtab(); |
| 354 | check.checkExtract("{addr1} {size1} {shndx1} FUNC GLOBAL DEFAULT hello"); |
| 355 | check.checkInSymtab(); |
| 356 | check.checkExtract("{addr2} {size2} {shndx2} FUNC GLOBAL DEFAULT world"); |
| 357 | check.checkComputeCompare("addr1 16 %", .{ .op = .eq, .value = .{ .literal = 0 } }); |
| 358 | check.checkComputeCompare("addr2 16 %", .{ .op = .eq, .value = .{ .literal = 0 } }); |
| 359 | test_step.dependOn(&check.step); |
| 360 | |
| 361 | const exe = addExecutable(b, opts); |
| 362 | addCSourceBytes(exe, |
| 363 | \\void greet(); |
| 364 | \\int main() { greet(); } |
| 365 | , &.{}); |
| 366 | exe.linkLibrary(dso); |
| 367 | exe.is_linking_libc = true; |
| 368 | |
| 369 | const run = addRunArtifact(exe); |
| 370 | run.expectStdOutEqual("Hello world"); |
| 371 | test_step.dependOn(&run.step); |
| 372 | |
| 373 | return test_step; |
| 374 | } |
| 375 | |
| 328 | 376 | fn testLinkingC(b: *Build, opts: Options) *Step { |
| 329 | 377 | const test_step = addTestStep(b, "linking-c", opts); |
| 330 | 378 | |