[LLVMdev] [lld] Relocation reading refactoring

Shankar Easwaran shankare at codeaurora.org
Wed Feb 26 09:42:15 PST 2014


Hi,

I was thinking of having a separate class that would return a vector of 
ELFReferences when you the reader looks at a section and symbol.

The class would be constructed with 
_relocationAddendReferences/_relocationReferences.

Each subtarget could make use of the functionality and create a 
different type of ELFReference on a need basis.

Thoughts ?

Thanks

Shankar Easwaran

On 2/26/2014 4:56 AM, Simon Atanasyan wrote:
> Hi Shankar,
>
> On Tue, Feb 12, 2013 at 10:46 PM, Shankar Easwaran
> <shankare at codeaurora.org> wrote:
>> Author: shankare
>> Date: Tue Feb 12 12:46:53 2013
>> New Revision: 174990
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=174990&view=rev
> [...]
>
>>     ELFDefinedAtom<ELFT> *createDefinedAtomAndAssignRelocations(
>>         StringRef symbolName, StringRef sectionName, const Elf_Sym *symbol,
>>         const Elf_Shdr *section, ArrayRef<uint8_t> content) {
>> @@ -380,6 +534,11 @@ private:
>>               (ri->r_offset < symbol->st_value + content.size())) {
>>             auto *ERef = new (_readerStorage)
>>                 ELFReference<ELFT>(ri, ri->r_offset - symbol->st_value, nullptr);
>> +          // Read the addend from the section contents
>> +          // TODO : We should move the way lld reads relocations totally from
>> +          // ELFObjectFile
>> +          int32_t addend = *(content.data() + ri->r_offset - symbol->st_value);
>> +          ERef->setAddend(addend);
>>             _references.push_back(ERef);
>>           }
> What do you mean by removing relocation reading from the
> ELFObjectFile? I considered to customize the relocation reading for
> MIPS targets and my first idea was to factor out ELFReference creation
> into a couple of virtual functions. The first one is for Elf_Rel, the
> second one is for Elf_Rela. Then I planned to override these functions
> in the MipsELFFile class. But it looks like you have more profound
> idea. Could you share it?
>
> Thanks.
>
> --
> Simon
>
>


-- 
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by the Linux Foundation




More information about the llvm-dev mailing list