authorgravatar for motiejus@jakstys.ltMotiejus Jakštys <motiejus@jakstys.lt> 2022-06-23 06:41:30+03:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-02-16 16:33:05-07:00
log4c7ca20da56d86636dfcc35a6982ad10b147cece
tree79d9593c4c67712ca5127e8b158dada78d8eada0
parent438b71155a6e86263c61a664a1af596fe9b210bd

[linker] add --no-undefined, -z undefs

Refs https://github.com/zigchroot/zig-chroot/issues/1

1 files changed, 8 insertions(+), 0 deletions(-)

src/main.zig+8
...@@ -488,10 +488,12 @@ const usage_build_generic =...@@ -488,10 +488,12 @@ const usage_build_generic =
488 \\ -fno-build-id (default) Saves a bit of time linking488 \\ -fno-build-id (default) Saves a bit of time linking
489 \\ --eh-frame-hdr Enable C++ exception handling by passing --eh-frame-hdr to linker489 \\ --eh-frame-hdr Enable C++ exception handling by passing --eh-frame-hdr to linker
490 \\ --emit-relocs Enable output of relocation sections for post build tools490 \\ --emit-relocs Enable output of relocation sections for post build tools
491 \\ --no-undefined Alias of -z defs
491 \\ -z [arg] Set linker extension flags492 \\ -z [arg] Set linker extension flags
492 \\ nodelete Indicate that the object cannot be deleted from a process493 \\ nodelete Indicate that the object cannot be deleted from a process
493 \\ notext Permit read-only relocations in read-only segments494 \\ notext Permit read-only relocations in read-only segments
494 \\ defs Force a fatal error if any undefined symbols remain495 \\ defs Force a fatal error if any undefined symbols remain
496 \\ undefs Reverse of -z defs
495 \\ origin Indicate that the object must have its origin processed497 \\ origin Indicate that the object must have its origin processed
496 \\ nocopyreloc Disable the creation of copy relocations498 \\ nocopyreloc Disable the creation of copy relocations
497 \\ now (default) Force all relocations to be processed on load499 \\ now (default) Force all relocations to be processed on load
...@@ -1333,6 +1335,8 @@ fn buildOutputType(...@@ -1333,6 +1335,8 @@ fn buildOutputType(
1333 linker_z_notext = true;1335 linker_z_notext = true;
1334 } else if (mem.eql(u8, z_arg, "defs")) {1336 } else if (mem.eql(u8, z_arg, "defs")) {
1335 linker_z_defs = true;1337 linker_z_defs = true;
1338 } else if (mem.eql(u8, z_arg, "undefs")) {
1339 linker_z_defs = false;
1336 } else if (mem.eql(u8, z_arg, "origin")) {1340 } else if (mem.eql(u8, z_arg, "origin")) {
1337 linker_z_origin = true;1341 linker_z_origin = true;
1338 } else if (mem.eql(u8, z_arg, "nocopyreloc")) {1342 } else if (mem.eql(u8, z_arg, "nocopyreloc")) {
...@@ -1879,6 +1883,8 @@ fn buildOutputType(...@@ -1879,6 +1883,8 @@ fn buildOutputType(
1879 linker_gc_sections = true;1883 linker_gc_sections = true;
1880 } else if (mem.eql(u8, arg, "-dead_strip_dylibs")) {1884 } else if (mem.eql(u8, arg, "-dead_strip_dylibs")) {
1881 dead_strip_dylibs = true;1885 dead_strip_dylibs = true;
1886 } else if (mem.eql(u8, arg, "--no-undefined")) {
1887 linker_z_defs = true;
1882 } else if (mem.eql(u8, arg, "--gc-sections")) {1888 } else if (mem.eql(u8, arg, "--gc-sections")) {
1883 linker_gc_sections = true;1889 linker_gc_sections = true;
1884 } else if (mem.eql(u8, arg, "--no-gc-sections")) {1890 } else if (mem.eql(u8, arg, "--no-gc-sections")) {
...@@ -1944,6 +1950,8 @@ fn buildOutputType(...@@ -1944,6 +1950,8 @@ fn buildOutputType(
1944 linker_z_notext = true;1950 linker_z_notext = true;
1945 } else if (mem.eql(u8, z_arg, "defs")) {1951 } else if (mem.eql(u8, z_arg, "defs")) {
1946 linker_z_defs = true;1952 linker_z_defs = true;
1953 } else if (mem.eql(u8, z_arg, "undefs")) {
1954 linker_z_defs = false;
1947 } else if (mem.eql(u8, z_arg, "origin")) {1955 } else if (mem.eql(u8, z_arg, "origin")) {
1948 linker_z_origin = true;1956 linker_z_origin = true;
1949 } else if (mem.eql(u8, z_arg, "nocopyreloc")) {1957 } else if (mem.eql(u8, z_arg, "nocopyreloc")) {