[PATCH] D36279: [Object] Fix ELFObjectFile<ELFT>::getRelocationOffset
Alexander Shaposhnikov via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 3 15:39:03 PDT 2017
Oh, i see,
many thanks for the explanation!
On Thu, Aug 3, 2017 at 2:54 PM, Rafael Avila de Espindola <
rafael.espindola at gmail.com> wrote:
> The specification says
>
> r_offset
> This member gives the location at which to apply the relocation action.
> For a relocatable file, the value is the byte offset from the beginning of
> the section to the storage unit affected by the relocation. For an
> executable file or a shared object, the value is the virtual address of the
> storage unit affected by the relocation.
>
> So there is no offset in a ET_DYN. In a ET_DYN r_offset, despite the
> name, gives an address.
>
> Cheers,
> Rafael
>
> Alexander Shaposhnikov via Phabricator via llvm-commits
> <llvm-commits at lists.llvm.org> writes:
>
> > alexshap created this revision.
> >
> > The assert in ELFObjectFile<ELFT>::getRelocationOffset appears to be
> incorrect.
> > For example, dynamic libraries have e_type set to ET_DYN and contain
> relocations at the same time.
> > The same issue might arise for some executables (e_type set to ET_EXEC).
> >
> >
> > Repository:
> > rL LLVM
> >
> > https://reviews.llvm.org/D36279
> >
> > Files:
> > ELFObjectFile.h
> >
> >
> > Index: ELFObjectFile.h
> > ===================================================================
> > --- ELFObjectFile.h
> > +++ ELFObjectFile.h
> > @@ -781,12 +781,9 @@
> >
> > template <class ELFT>
> > uint64_t ELFObjectFile<ELFT>::getRelocationOffset(DataRefImpl Rel)
> const {
> > - assert(EF.getHeader()->e_type == ELF::ET_REL &&
> > - "Only relocatable object files have relocation offsets");
> > const Elf_Shdr *sec = getRelSection(Rel);
> > if (sec->sh_type == ELF::SHT_REL)
> > return getRel(Rel)->r_offset;
> > -
> > return getRela(Rel)->r_offset;
> > }
> >
> >
> >
> > Index: ELFObjectFile.h
> > ===================================================================
> > --- ELFObjectFile.h
> > +++ ELFObjectFile.h
> > @@ -781,12 +781,9 @@
> >
> > template <class ELFT>
> > uint64_t ELFObjectFile<ELFT>::getRelocationOffset(DataRefImpl Rel)
> const {
> > - assert(EF.getHeader()->e_type == ELF::ET_REL &&
> > - "Only relocatable object files have relocation offsets");
> > const Elf_Shdr *sec = getRelSection(Rel);
> > if (sec->sh_type == ELF::SHT_REL)
> > return getRel(Rel)->r_offset;
> > -
> > return getRela(Rel)->r_offset;
> > }
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170803/9b254789/attachment.html>
More information about the llvm-commits
mailing list