.init_array and .fini_array are easy because they're just a list of functions, but .init and .fini appears to be code to execute:
Code: Select all
Disassembly of section .init:
000000000000ecbc <.init>:
ecbc: e8 af f8 ff ff call 0xe570 <__fixunssfti+0x80>
Disassembly of section .fini:
000000000000ecc1 <.fini>:
ecc1: e8 fa f8 ff ff call 0xe5c0 <__fixunssfti+0xd0>
I was thinking of copying this code somewhere and putting a `ret` opcode so it's a callable function, but "e8" is near call relative (because the dynamically loaded library is position independent code), so I'd have to patch up any PIC I'd copy.
Surely there is an easier way? Can I force Clang/LLD to make .init not be a naked function (so it returns to the caller?) How are dynamic loaders suppose to execute the code in .init?