Closed brooksdavis closed 6 years ago
I presume that this is because the address of _DefaultRuneLocale
is not known statically and capsizefix
doesn't know about dynamic relocations. If we had a proper linker, then the address would be 0 and there would be a dynamic relocation for the symbol. We probably need to do something similar, but I'm not sure how much it's worth continuing to pile hacks into capsizefix vs starting to emit proper dynamic relocs.
Note: Not using -cheri-linker
for dynamic binaries will probably fix this, as we'll then end up with the initialisers being generated as executable code.
It might also be fairly simple to have capsizefix
look at dynamic relocs and ignore any entries that have address 0 and dynamic relocs applied. We would still need rtld
to do the same thing as capsizefix
for addresses that had dynamic relocs.
_DefaultRuneLocale
is defined and initialized in this in this translation unit. Having capsizefix
ignore unresolved dynamic objects probably does make sense.
It doesn't matter that it's defined in this compilation unit. The address of the global, in a PIC translation unit, is not known until compile time. In code, it doesn't matter because its offset from the code is known at (static) link time and so you can do a PC-relative static relocation and then a PC-relative load, but that's not the case here: we need to generate a capability that has an address that isn't known until load time. In a normal dynamically linked application, this will be handled by a dynamic relocation, but we don't currently have dynamic relocations for capabilities.
Note that capsizefix can't easily emit relocations here either: it is doing in-place modification of the binary and doing this properly would require doing something more like a linker and emitting a new modified binary with larger reloc sections.
This is OBE and cap-table will should finish the job.
When compiling
libc/local/table.c
, we have an initializer for_DefaultRuneLocale
followed
Despite them being in the same translation unit, the capreloc entry for
_CurrentRuneLocale
ends up being:In libc,
capsizefix
further compounds the problem by deciding that the size of objects with address0
have a size of 0x80. For simple testing, the following Makefile installed in a subdirectory ofsrc/lib
compileslocale/table.c
by it self. An up to date tree is required to build a shared library.