Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/preview' into gfx-rdp
Browse files Browse the repository at this point in the history
  • Loading branch information
rasky committed Dec 23, 2024
2 parents a5dc600 + 9e41dcb commit 48f8521
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion dso.ld
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ SECTIONS {
/* Write constructors and destructors which each must be 4-byte aligned */
.ctors ALIGN(4) : {
LONG(0); /* Add terminator to CTOR list */
KEEP(*(SORT(.ctors.*)))
KEEP(*(.ctors))
KEEP(*(SORT(.ctors.*)))
__CTOR_LIST__ = .-4; /* Define symbol for CTOR list */
}

Expand Down
4 changes: 3 additions & 1 deletion n64.ld
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ SECTIONS {
__wrap___do_global_ctors and enables it via the --wrap linker option.
When linking with ld, we should use __do_global_ctors, which is the default
if you don't provide the --wrap option. */
KEEP(*(.ctors))
KEEP(*(EXCLUDE_FILE (*crtend.o) .ctors))
KEEP(*(SORT(.ctors.*)))
KEEP(*crtend.o(.ctors))
/* Similarly we should have a;

LONG(0)
Expand Down
14 changes: 14 additions & 0 deletions tests/test_constructors.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
extern unsigned int __global_cpp_constructor_test_value;

unsigned int __global_constructor_test_value;
unsigned int __global_constructor_test_value_old;
unsigned int __global_constructor_test_prio;

__attribute__((constructor(123))) void __global_constructor_test_prio1(void)
{
__global_constructor_test_prio = 0xC0C70123;
}

__attribute__((constructor(125))) void __global_constructor_test_prio2(void)
{
__global_constructor_test_value_old = __global_constructor_test_value;
__global_constructor_test_prio = 0xE0C70125;
}

__attribute__((constructor)) void __global_constructor_test()
{
Expand All @@ -10,4 +23,5 @@ __attribute__((constructor)) void __global_constructor_test()
void test_constructors(TestContext *ctx) {
ASSERT(__global_constructor_test_value == 0xC0C70125, "Global constructors did not get executed!");
ASSERT(__global_cpp_constructor_test_value == 0xD0C70125, "Global C++ constructors did not get executed!");
ASSERT(__global_constructor_test_prio == 0xE0C70125 && __global_constructor_test_value_old == 0, "Global constructors with priority don't work correctly!");
}

0 comments on commit 48f8521

Please sign in to comment.