Skip to content

Commit d0e8fed

Browse files
Include linker generated symbol in default defined set
It seems like `_GLOBAL_OFFSET_TABLE_` is defined by the linker without being present in any object file on x86_64. There are a few other symbols that the linker automatically defines although we haven't run into issues with them. I am including the full list I gathered from lld's source code [1] by default. [1] https://github.com/llvm/llvm-project/blob/177e38286cd61a7b5a968636e1f147f128dd25a2/lld/ELF/Config.h#L632
1 parent 2096cff commit d0e8fed

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

Sources/BinarySymbols/ReferencedSymbols.swift

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,26 @@ package struct ReferencedSymbols {
1313
package private(set) var undefined: Set<String>
1414

1515
package init() {
16-
self.defined = []
16+
// Some symbols are defined by linker directly by convention and need to be assumed defined.
17+
// The list below was pulled from
18+
// https://github.com/llvm/llvm-project/blob/177e38286cd61a7b5a968636e1f147f128dd25a2/lld/ELF/Config.h#L632
19+
self.defined = [
20+
"__bss_start",
21+
"_etext",
22+
"etext",
23+
"_edata",
24+
"edata",
25+
"_end",
26+
"end",
27+
"_GLOBAL_OFFSET_TABLE_",
28+
"_gp",
29+
"_gp_disp",
30+
"__gnu_local_gp",
31+
"__global_pointer$",
32+
"__rela_iplt_start",
33+
"__rela_iplt_end",
34+
"_TLS_MODULE_BASE",
35+
]
1736
self.undefined = []
1837
}
1938

0 commit comments

Comments
 (0)