Re:ELF Binaries and Relocation Entries
by bogomipz on Saturday November 30, 2019 @02:17PM
(#21671667)
Thank you. Yes now I think I understand. I had a follow up question. You state:
">As we saw above, a simple program resulted in 2 different relocation entries just to compose the address of 1 variable. We saw:
R_OR1K_AHI16 R_OR1K_LO_16_IN_INSN"
Can you say why two relocations are needed? I understand the address of x is not known until link time however what would the second relocation be for?
Also is there a good reference for deciphering the relocation names?
Re:ELF Binaries and Relocation Entries
by stffrdhrn on Sunday December 01, 2019 @08:37AM
(#21675415)
Hello, There are 2 relocations because the series of instructions that needs to create a 32-bit memory address requires HI16 and LO_16 relocations. The 2 relocations sure 16-bit high and low bitfields to compose the 32-bit address.
For a full list of relocation types see the list in the last few links of the article. Note, the OpenRISC relocations are not all well documented.
I see, the relocations happen in pairs then - lower order and high order bits. Is that correct?
Re:ELF Binaries and Relocation Entries
by stffrdhrn on Monday December 02, 2019 @06:59AM
(#21681671)
Yes, for OpenRISC as there are no instructions with a 32-bit immediate so we use 2 high and low order relocations. However, on machines like x86 they have variable width instructions and support 32-bit relocations, they can get by with a single relocation entry.
Addend is actually usually 0 and important as a optimization for directly accessing indexed array values. It is not usually explained very well so I hope its clear now.
If there is anything else that could use clarification I am happy to update the article or answer questions.