<div dir="ltr">Oh, i see, <div>many thanks for the explanation!</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Aug 3, 2017 at 2:54 PM, Rafael Avila de Espindola <span dir="ltr"><<a href="mailto:rafael.espindola@gmail.com" target="_blank">rafael.espindola@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">The specification says<br>
<br>
r_offset<br>
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.<br>
<br>
So there is no offset in a ET_DYN. In a ET_DYN r_offset, despite the<br>
name, gives an address.<br>
<br>
Cheers,<br>
Rafael<br>
<br>
Alexander Shaposhnikov via Phabricator via llvm-commits<br>
<div><div class="h5"><<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a>> writes:<br>
<br>
> alexshap created this revision.<br>
><br>
> The assert in ELFObjectFile<ELFT>::<wbr>getRelocationOffset appears to be incorrect.<br>
> For example, dynamic libraries have e_type set to ET_DYN and contain relocations at the same time.<br>
> The same issue might arise for some executables (e_type set to ET_EXEC).<br>
><br>
><br>
> Repository:<br>
> rL LLVM<br>
><br>
> <a href="https://reviews.llvm.org/D36279" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D36279</a><br>
><br>
> Files:<br>
> ELFObjectFile.h<br>
><br>
><br>
> Index: ELFObjectFile.h<br>
> ==============================<wbr>==============================<wbr>=======<br>
> --- ELFObjectFile.h<br>
> +++ ELFObjectFile.h<br>
> @@ -781,12 +781,9 @@<br>
><br>
> template <class ELFT><br>
> uint64_t ELFObjectFile<ELFT>::<wbr>getRelocationOffset(<wbr>DataRefImpl Rel) const {<br>
> - assert(EF.getHeader()->e_type == ELF::ET_REL &&<br>
> - "Only relocatable object files have relocation offsets");<br>
> const Elf_Shdr *sec = getRelSection(Rel);<br>
> if (sec->sh_type == ELF::SHT_REL)<br>
> return getRel(Rel)->r_offset;<br>
> -<br>
> return getRela(Rel)->r_offset;<br>
> }<br>
><br>
><br>
><br>
> Index: ELFObjectFile.h<br>
> ==============================<wbr>==============================<wbr>=======<br>
> --- ELFObjectFile.h<br>
> +++ ELFObjectFile.h<br>
> @@ -781,12 +781,9 @@<br>
><br>
> template <class ELFT><br>
> uint64_t ELFObjectFile<ELFT>::<wbr>getRelocationOffset(<wbr>DataRefImpl Rel) const {<br>
> - assert(EF.getHeader()->e_type == ELF::ET_REL &&<br>
> - "Only relocatable object files have relocation offsets");<br>
> const Elf_Shdr *sec = getRelSection(Rel);<br>
> if (sec->sh_type == ELF::SHT_REL)<br>
> return getRel(Rel)->r_offset;<br>
> -<br>
> return getRela(Rel)->r_offset;<br>
> }<br>
><br>
</div></div>> ______________________________<wbr>_________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>