Repository: davidlattimore/wild (rust)

Issue:
Add support for -z defs
The flag `-z defs` affects linking of shared objects. It should mean that we give an error if a symbol is referenced, but not defined, where normally, for shared objects, we don't do that.

The test can probably be something similar to this.

```c
//#LinkArgs:-Bshareable -z defs
//#Static:false
//#ExpectError:foo

int foo(void);

int call_foo(void) {
    return foo() + 2;
}
```

Pull request description:
add: defs z option
Add defs option for z flag. Closes #810


Patch:
diff --git a/libwild/src/args.rs b/libwild/src/args.rs
index 9bf62a6..7d610cb 100644
--- a/libwild/src/args.rs
+++ b/libwild/src/args.rs
@@ -355,6 +355,7 @@ pub(crate) fn parse<F: Fn() -> I, S: AsRef<str>, I: Iterator<Item = S>>(input: F
                 "noexecstack" => args.execstack = false,
                 "nocopyreloc" => args.allow_copy_relocations = false,
                 "nodelete" => args.needs_nodelete_handling = true,
+                "defs" => args.no_undefined = true,
                 _ => {
                     warn_unsupported(&format!("-z {arg}"))?;
                     // TODO: Handle these


Test patch:
diff --git a/wild/tests/integration_tests.rs b/wild/tests/integration_tests.rs
index fa09a38..1e4fcfe 100644
--- a/wild/tests/integration_tests.rs
+++ b/wild/tests/integration_tests.rs
@@ -2371,7 +2371,8 @@ fn integration_test(
         "shared.c",
         "duplicate_strong_symbols.c",
         "preinit-array.c",
-        "exception.cc"
+        "exception.cc",
+        "z-defs.c"
     )]
     program_name: &'static str,
     #[allow(unused_variables)] setup_symlink: (),
diff --git a/wild/tests/sources/z-defs.c b/wild/tests/sources/z-defs.c
new file mode 100644
index 0000000..b549f33
--- /dev/null
+++ b/wild/tests/sources/z-defs.c
@@ -0,0 +1,7 @@
+//#LinkArgs:-Bshareable -z defs
+//#Static:false
+//#ExpectError:foo
+
+int foo(void);
+
+int call_foo(void) { return foo() + 2; }