[llvm-commits] ELFReader.cpp update - Add support for References.
Bill Wendling
wendling at apple.com
Wed Sep 12 11:32:18 PDT 2012
On Sep 11, 2012, at 1:24 PM, "Clow, Marshall" <mclow at qualcomm.com> wrote:
> On Sep 11, 2012, at 12:50 PM, Bill Wendling <wendling at apple.com> wrote:
>> On Sep 11, 2012, at 11:49 AM, "Clow, Marshall" <mclow at qualcomm.com> wrote:
>>> On Sep 11, 2012, at 11:21 AM, Sid Manning <sidneym at codeaurora.org> wrote:
>>>
>>>> On 09/07/12 16:45, Michael Spencer wrote:
>>>>> On Fri, Sep 7, 2012 at 8:41 AM, Sid Manning<sidneym at codeaurora.org> wrote:
>>>>>>
>>>> ....
>>>>>
>>>>>> + (reinterpret_cast<const Elf_Rela *>(contents.data()));
>>>>>> +
>>>>>> + // Get rid of the leading .rela so Atoms can use their own section
>>>>>> + // name to find the relocs.
>>>>>> + sectionName = sectionName.drop_front(5);
>>>>>> +
>>>>>> + auto&ref = RelocationAddendReferences[sectionName];
>>>>>
>>>>> Ref.
>>>>>
>>>>>> + for (unsigned int i=0; i<section->getEntityCount(); i++) {
>>>>>> + ref.push_back(relocs+i);
>>>>>
>>>>> This is still wrong. The offset to use for each relocation entry is based on
>>>>> sh_entsize. See the getRel and getEntry templates in Object/ELF.h. We can expose
>>>>> these, or better yet, proper iterators to them. I dislike duplicating the work
>>>>> of file format parsing.
>>>>>
>>>>
>>>> OK I can push this up to ELF.h by adding a new interface, getELFRelaVector(Elf_Shdr *) that returns relocations in a vector.
>>>
>>> While I like the
>>> I don't like embedding the return type in the name of the function.
>>> How about (something like):
>>> std::vector <const Elf_Rel *> getSectionRelocations ( section );
>>>
>> Instead of returning a std::vector, please pass in a reference and fill that.
>
> Why?
>
If it has move semantics, then it's fine. Otherwise, it will cause a copy of the vector from a temporary to the final one, which is expensive.
-bw
More information about the llvm-commits
mailing list