[solved] clang, uefi and global constructors
Posted: Mon Aug 30, 2021 7:04 pm
I am using clang to cross-compile a UEFI bootloader (I use "-target x86_64-unknown-windows"). I would like to call global constructors before running any other code. I am not able to find the usual suspects ".init_array", "__CTOR_LIST__", "__init()" etc. Of course I am not linking any of the crtxxx stuff as this is a "bare metal" target.
Dumping the PDB I can see that there are references to global constructors (so they are generated):
Dumping the PE file, I see a ".CRT" section that might or might not be related. It basically contains some address that points within the code, but I am not sure what is going on here.
What I cannot find is a way to run them on entry. The googles are not working today. Any idea?
Dumping the PDB I can see that there are references to global constructors (so they are generated):
Code: Select all
0x1006 | LF_FUNC_ID [size = 48, hash = 0x38C6C]
name = `dynamic initializer for 'g_test', type = 0x102E, parent scope = <no type>
0x10B3 | LF_FUNC_ID [size = 52, hash = 0x2B878]
name = metal::`dynamic initializer for 'g_log', type = 0x102E, parent scope = <no type>
5976 | S_LPROCREF [size = 48] ``dynamic initializer for 'g_test'`
module = 1, sum name = 0, offset = 236
11592 | S_LPROCREF [size = 56] `metal::`dynamic initializer for 'g_log'`
module = 11, sum name = 0, offset = 52
6244 | S_GDATA32 [size = 24] `g_test`
type = 0x1033 (Test), addr = 0003:0032
11916 | S_GDATA32 [size = 28] `metal::g_log`
type = 0x119E (metal::LogSystem), addr = 0003:1032
What I cannot find is a way to run them on entry. The googles are not working today. Any idea?