[PATCH] Fix MCDataAtom never calling remap when adding data.

Stephen Checkoway s at pahtak.org
Wed Oct 16 07:39:21 PDT 2013


On Oct 16, 2013, at 9:51 AM, Rafael EspĂ­ndola <rafael.espindola at gmail.com> wrote:

> On 16 October 2013 09:16, Rafael EspĂ­ndola <rafael.espindola at gmail.com> wrote:
>> Can this be tested via llvm-mc?
> 
> I now see that it is used from the disassembler. Every current users
> creates the Atom with as much space as it will ever need.
> 
> The case of
> 
> InvalidData = Module->createDataAtom(CurAddr, EndAddr);
> 
> looks like a bug. The atom is made to go all the way to the end of
> section, but we keep trying to disassemble. If we succeed we will have
> overlapping atoms.

I think you're right. What do you think the correct behavior here should be? I can think of a few possibilities:

1. Truncate the text atom after the last valid instruction and add a data atom for the remainder of the section.
2. Truncate the text atom, add a data atom of size 1, and attempt to disassemble starting with the next byte, creating a new text atom if it succeeds.
3. Perform a smarter disassembly. Section 2.2 of <http://0b4af6cdc2f0c5998459-c0245c5c937c5dedcca3f1764ecc9b2f.r43.cf2.rackcdn.com/12313-sec13-paper_zhang.pdf> (which won best paper award at USENIX Security this year) offers a mixed linear and recursive disassembly approach which apparently works well in practice.

> In other words, there are not that many users, so the patch with the
> unit test LGTM.


Great.

-- 
Stephen Checkoway









More information about the llvm-commits mailing list