| ... | ... | @@ -77,6 +77,7 @@ pub fn build(b: *Build) void { |
| 77 | 77 | elf_step.dependOn(testPie(b, .{ .target = glibc_target })); |
| 78 | 78 | elf_step.dependOn(testPltGot(b, .{ .target = glibc_target })); |
| 79 | 79 | elf_step.dependOn(testPreinitArray(b, .{ .target = glibc_target })); |
| 80 | elf_step.dependOn(testSharedAbsSymbol(b, .{ .target = glibc_target })); |
| 80 | 81 | } |
| 81 | 82 | |
| 82 | 83 | fn testAbsSymbols(b: *Build, opts: Options) *Step { |
| ... | ... | @@ -1642,6 +1643,68 @@ fn testPreinitArray(b: *Build, opts: Options) *Step { |
| 1642 | 1643 | return test_step; |
| 1643 | 1644 | } |
| 1644 | 1645 | |
| 1646 | fn testSharedAbsSymbol(b: *Build, opts: Options) *Step { |
| 1647 | const test_step = addTestStep(b, "shared-abs-symbol", opts); |
| 1648 | |
| 1649 | const dso = addSharedLibrary(b, "a", opts); |
| 1650 | addAsmSourceBytes(dso, |
| 1651 | \\.globl foo |
| 1652 | \\foo = 3; |
| 1653 | ); |
| 1654 | |
| 1655 | const obj = addObject(b, "obj", opts); |
| 1656 | addCSourceBytes(obj, |
| 1657 | \\#include <stdio.h> |
| 1658 | \\extern char foo; |
| 1659 | \\int main() { printf("foo=%p\n", &foo); } |
| 1660 | , &.{}); |
| 1661 | obj.force_pic = true; |
| 1662 | obj.linkLibC(); |
| 1663 | |
| 1664 | { |
| 1665 | const exe = addExecutable(b, "main1", opts); |
| 1666 | exe.addObject(obj); |
| 1667 | exe.linkLibrary(dso); |
| 1668 | exe.pie = true; |
| 1669 | |
| 1670 | const run = addRunArtifact(exe); |
| 1671 | run.expectStdOutEqual("foo=0x3\n"); |
| 1672 | test_step.dependOn(&run.step); |
| 1673 | |
| 1674 | const check = exe.checkObject(); |
| 1675 | check.checkStart(); |
| 1676 | check.checkExact("header"); |
| 1677 | check.checkExact("type DYN"); |
| 1678 | // TODO fix/improve in CheckObject |
| 1679 | // check.checkInSymtab(); |
| 1680 | // check.checkNotPresent("foo"); |
| 1681 | test_step.dependOn(&check.step); |
| 1682 | } |
| 1683 | |
| 1684 | // https://github.com/ziglang/zig/issues/17430 |
| 1685 | // { |
| 1686 | // const exe = addExecutable(b, "main2", opts); |
| 1687 | // exe.addObject(obj); |
| 1688 | // exe.linkLibrary(dso); |
| 1689 | // exe.pie = false; |
| 1690 | |
| 1691 | // const run = addRunArtifact(exe); |
| 1692 | // run.expectStdOutEqual("foo=0x3\n"); |
| 1693 | // test_step.dependOn(&run.step); |
| 1694 | |
| 1695 | // const check = exe.checkObject(); |
| 1696 | // check.checkStart(); |
| 1697 | // check.checkExact("header"); |
| 1698 | // check.checkExact("type EXEC"); |
| 1699 | // // TODO fix/improve in CheckObject |
| 1700 | // // check.checkInSymtab(); |
| 1701 | // // check.checkNotPresent("foo"); |
| 1702 | // test_step.dependOn(&check.step); |
| 1703 | // } |
| 1704 | |
| 1705 | return test_step; |
| 1706 | } |
| 1707 | |
| 1645 | 1708 | fn testTlsStatic(b: *Build, opts: Options) *Step { |
| 1646 | 1709 | const test_step = addTestStep(b, "tls-static", opts); |
| 1647 | 1710 | |