浏览代码

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 年之前
父节点
当前提交
b3cc412aad
共有 1 个文件被更改,包括 1 次插入1 次删除
  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();