Browse Source

entry.c: .ctors is run backwards

Store forwards, run backwards (65535 to 0)
Ref: https://github.com/bminor/binutils-gdb/blob/5a8e7e1332c35d4d5bed67adccd9d66f5cf62c4e/ld/scripttempl/elf.sc#L310
Ref: https://sourceware.org/binutils/docs/ld/Input-Section-Wildcards.html

Signed-off-by: Callum Farmer <gmbr3@opensuse.org>
Callum Farmer 1 year ago
parent
commit
b3cc412aad
1 changed files with 1 additions and 1 deletions
  1. 1 1
      lib/entry.c

+ 1 - 1
lib/entry.c

@@ -28,7 +28,7 @@ static void ctors(void)
 			func();
 	}
 
-	for (funcp *location = (void *)&__CTOR_LIST__; location < (funcp *)&__CTOR_END__; location++) {
+	for (funcp *location = (void *)&__CTOR_END__; location > (funcp *)&__CTOR_LIST__; location--) {
 		funcp func = *location;
 		if (location != NULL)
 			func();