I am looking for an easy way to reorder ELF file sections. I have a sequence of user partitions that I would like everyone to be aligned in a specific order.
The only way I found is to use the linker script. However, the documentation states that specifying a custom linker script overrides the default value. The default linker of the script has a lot of content in it, which I donβt want to duplicate in my custom script in order to get the three sections always together in a certain order. It does not seem very flexible to hard code the linker behavior in this way.
Why do I want to do this? I have a data section in which I need to know the location of memory at runtime (start and end). Therefore, I created two additional sections and introduced control variables in them. Then I want to use the memory cells of these variables to find out the size of an unknown section in memory.
.markerA int markerA; .targetSection ... Lots of variables ... .markerB int markerB;
In the above example, I would know that the data in .targetSection is between the address of marker A and marker B.
Is there any other way to do this? Are there libraries that will allow me to read the current executable ELF image and determine the location and size of the partition?
linux elf
MrSlippers
source share