<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Aug 25, 2015 at 2:30 AM, Simon Cook via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I've been trying to write a tool that reads in an ELF file and modifies<br>
one section within that ELF file based on the data contained within<br>
another section. Using llvm-objdump as a template of how to read an<br>
object file, I've been able to read the latter section that tells me<br>
what to edit, but I haven't found a way to edit the former, as<br>
everything in the MCSection/ELFObjectFile/SectionRef classes seem to be<br>
read-only as far as section contents are concerned.<br>
<br>
The changes I would want to make don't change the size of any section,<br>
all I need to do is for example zero the first n bytes of .text whilst<br>
keeping the rest of the object the same. What would be the recommended<br>
approach to achieving this goal?<br></blockquote><div><br></div><div>Just get a reference to the bytes you want to edit and then write through the returned pointer. Just make that the file is mapped as writable, otherwise you will obviously segfault.</div><div><br></div><div>-- Sean Silva</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Thanks,<br>
Simon<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div><br></div></div>