33forge LinkerBuildIdZTests {
44 const ERR_OK: UInt32 = 0;
55 const ERR_UNSUPPORTED_FLAG: UInt32 = 12;
6+ const ERR_CONFLICTING_OPTIONS: UInt32 = 16;
67
78 const BUILD_ID_MODE_NONE: UInt32 = 0;
89 const BUILD_ID_MODE_FAST: UInt32 = 1;
@@ -129,6 +130,31 @@ forge LinkerBuildIdZTests {
129130 return expect_u32(s3, ERR_OK);
130131 }
131132
133+ proc K::test_z_extended_compat_tokens_accepted() -> UInt32 {
134+ DustLink::K::reset_state();
135+ let s1 = DustLink::K::set_z_option("separate-code");
136+ if s1 ! ERR_OK { return 0; }
137+ let s2 = DustLink::K::set_z_option("pack-relative-relocs");
138+ if s2 ! ERR_OK { return 0; }
139+ let s3 = DustLink::K::set_z_option("max-page-size=0x1000");
140+ if s3 ! ERR_OK { return 0; }
141+ let s4 = DustLink::K::set_z_option("common-page-size=0x1000");
142+ if s4 ! ERR_OK { return 0; }
143+ let s5 = DustLink::K::set_z_option("stack-size=0x400000");
144+ return expect_u32(s5, ERR_OK);
145+ }
146+
147+ proc K::test_z_muldefs_nomuldefs_toggle() -> UInt32 {
148+ DustLink::K::reset_state();
149+ let s1 = DustLink::K::set_z_option("muldefs");
150+ if s1 ! ERR_OK { return 0; }
151+ let a = host_linker_get_allow_multiple_definition();
152+ let s2 = DustLink::K::set_z_option("nomuldefs");
153+ if s2 ! ERR_OK { return 0; }
154+ let b = host_linker_get_allow_multiple_definition();
155+ return expect_u32(a, 1) * expect_u32(b, 0);
156+ }
157+
132158 proc K::test_dynamic_mode_toggles() -> UInt32 {
133159 DustLink::K::reset_state();
134160 let s1 = DustLink::K::set_shared(1);
@@ -259,6 +285,44 @@ forge LinkerBuildIdZTests {
259285 return expect_u32(a, 1) * expect_u32(b, 0);
260286 }
261287
288+ proc K::test_push_pop_state_restores_link_policy() -> UInt32 {
289+ DustLink::K::reset_state();
290+ DustLink::K::set_static(0);
291+ DustLink::K::set_as_needed(0);
292+ DustLink::K::set_whole_archive(0);
293+ DustLink::K::set_new_dtags(1);
294+ DustLink::K::set_copy_dt_needed_entries(0);
295+ DustLink::K::set_no_undefined(0);
296+ let push = DustLink::K::push_state();
297+ if push ! ERR_OK { return 0; }
298+ DustLink::K::set_static(1);
299+ DustLink::K::set_as_needed(1);
300+ DustLink::K::set_whole_archive(1);
301+ DustLink::K::set_new_dtags(0);
302+ DustLink::K::set_copy_dt_needed_entries(1);
303+ DustLink::K::set_no_undefined(1);
304+ let pop = DustLink::K::pop_state();
305+ if pop ! ERR_OK { return 0; }
306+ let a = host_linker_get_static();
307+ let b = host_linker_get_as_needed();
308+ let c = host_linker_get_whole_archive();
309+ let d = host_linker_get_new_dtags();
310+ let e = host_linker_get_copy_dt_needed_entries();
311+ let f = host_linker_get_no_undefined();
312+ return expect_u32(a, 0)
313+ * expect_u32(b, 0)
314+ * expect_u32(c, 0)
315+ * expect_u32(d, 1)
316+ * expect_u32(e, 0)
317+ * expect_u32(f, 0);
318+ }
319+
320+ proc K::test_pop_state_without_push_rejected() -> UInt32 {
321+ DustLink::K::reset_state();
322+ let status = DustLink::K::pop_state();
323+ return expect_u32(status, ERR_CONFLICTING_OPTIONS);
324+ }
325+
262326 proc K::test_sysroot_roundtrip() -> UInt32 {
263327 DustLink::K::reset_state();
264328 let status = DustLink::K::set_sysroot("/opt/xdv-sysroot");
@@ -363,6 +427,8 @@ forge LinkerBuildIdZTests {
363427 + test_z_invalid_rejected()
364428 + test_z_defs_undefs_toggle_no_undefined()
365429 + test_z_text_family_accepted()
430+ + test_z_extended_compat_tokens_accepted()
431+ + test_z_muldefs_nomuldefs_toggle()
366432 + test_dynamic_mode_toggles()
367433 + test_dynamic_linker_and_soname_set()
368434 + test_needed_library_note_normalization()
@@ -371,6 +437,8 @@ forge LinkerBuildIdZTests {
371437 + test_no_undefined_toggle()
372438 + test_dynamic_unresolved_policy_gate()
373439 + test_whole_archive_toggle()
440+ + test_push_pop_state_restores_link_policy()
441+ + test_pop_state_without_push_rejected()
374442 + test_sysroot_roundtrip()
375443 + test_rpath_roundtrip()
376444 + test_rpath_link_roundtrip()
0 commit comments