<br><br><div class="gmail_quote">On Thu, Oct 18, 2012 at 2:24 PM, NAKAMURA Takumi <span dir="ltr"><<a href="mailto:geek4civic@gmail.com" target="_blank">geek4civic@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="im">>>   > Besides, I still want the offsets to be meaningful for addr2line/atos.<br>
>><br>
>>     #0 0x804a7e6<br>
>> (projects/compiler-rt/lib/asan/lit_tests/Output/use-after-free.cc.tmp+0x27e6)<br>
>><br>
>>   Then should the address (0x804a7e6) be taken by them instead of the<br>
>> offset (0x27e6)?<br>
><br>
><br>
> I probably miss something here. As I understand, your non-PIE binary code<br>
> segment<br>
> is loaded at 0x8048000, right? What do you see when you run "objdump -d" on<br>
> this binary?<br>
> Does the instruction addresses have the form 0x804.... as well? If they do,<br>
> we want the<br>
> first line to have the form<br>
> #0 0x804a7e6<br>
> (projects/compiler-rt/lib/asan/lit_tests/Output/use-after-free.cc.tmp+0x804a7e6)<br>
> as well, for compatibility with addr2line, objdump etc.<br>
<br>
</div>It was the emission of patched version of non-relocatable executable.<br>
<br>
With objdump -x,<br>
<br>
    LOAD off    0x00000000 vaddr 0x08048000 paddr 0x08048000 align 2**12<br>
         filesz 0x0002215c memsz 0x0002215c flags r-x<br>
<br>
with objdump -d,<br>
<br>
projects/compiler-rt/lib/asan/lit_tests/Output/use-after-free.cc.tmp:<br>
   file format elf32-i386<br>
<br>
<br>
Disassembly of section .init:<br>
<br>
0804a46c <_init>:<br>
 804a46c:       55                      push   %ebp<br>
(snip)<br>
<br>
Disassembly of section .plt:<br>
<br>
0804a49c <abort@plt-0x10>:<br>
 804a49c:       ff 35 b4 b3 06 08       pushl  0x806b3b4<br>
(snip)<br>
<br>
Disassembly of section .text:<br>
<br>
0804a6e0 <_start>:<br>
 804a6e0:       31 ed                   xor    %ebp,%ebp<br>
(snip)<br>
<br>
0804a7a0 <main>:<br>
 804a7a0:       55                      push   %ebp<br>
(snip)<br>
 804a7dd:       5d                      pop    %ebp<br>
 804a7de:       c3                      ret<br>
 804a7df:       89 34 24                mov    %esi,(%esp)<br>
 804a7e2:       e8 19 0b 00 00          call   804b300 <__asan_report_load1><br>
 804a7e7:       66 0f 1f 84 00 00 00    nopw   0x0(%eax,%eax,1)<br>
 804a7ee:       00 00<br>
<br>
FYI, addr2line show me;<br>
<br>
$ echo 0x804a7e6 | addr2line -f -e<br>
projects/compiler-rt/lib/asan/lit_tests/Output/use-after-free.cc.tmp<br>
main<br>
llvm-project/compiler-rt/lib/asan/lit_tests/use-after-free.cc:22<br>
<div class="im"><br>
> If they do,<br>
> we want the<br>
> first line to have the form<br>
> #0 0x804a7e6<br>
> (projects/compiler-rt/lib/asan/lit_tests/Output/use-after-free.cc.tmp+0x804a7e6)<br>
> as well, for compatibility with addr2line, objdump etc.<br>
<br>
</div>I didn't know any other tools who expect such a form. Did you say<br>
binutils would recognize one?<br>
<div class="im"><br>
<br>
>>   Anyways, I don't know how to distinguish PIE in runtime, though.<br>
><br>
> Yeah, neither do I (for now). Now to check if the module is main non-PIE<br>
> binary we check if<br>
> the module is first in the list of mappings. We can instead invent more<br>
> loose (but still hacky)<br>
> condition - the module address should be "small" (say, in the lower half of<br>
> address space), and<br>
> its name shouldn't have a dynamic library suffix.<br>
<br>
</div>Your assumption does not work for me.<br>
On centos6 x86-64 with i386, I saw the map like;<br></blockquote><div><br></div><div>I wonder if you can build with -fPIE -pie. The may fix the current problem for you. </div><div>It is also a good idea anyway -- I really wish we could make -pie the default mode for asan, at least on Linux</div>
<div>(this will save ~ 5% performance and code size if used with zero shadow access)</div><div><br></div><div>--kcc </div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<br>
0012a000-0012b000 r-xp 00000000 00:00 0                  [vdso]<br>
0051a000-00538000 r-xp 00000000 08:01 3809599            /lib/<a href="http://ld-2.12.so" target="_blank">ld-2.12.so</a><br>
00538000-00539000 r--p 0001d000 08:01 3809599            /lib/<a href="http://ld-2.12.so" target="_blank">ld-2.12.so</a><br>
00539000-0053a000 rw-p 0001e000 08:01 3809599            /lib/<a href="http://ld-2.12.so" target="_blank">ld-2.12.so</a><br>
00cde000-00e6e000 r-xp 00000000 08:01 3806639            /lib/<a href="http://libc-2.12.so" target="_blank">libc-2.12.so</a><br>
00e6e000-00e70000 r--p 0018f000 08:01 3806639            /lib/<a href="http://libc-2.12.so" target="_blank">libc-2.12.so</a><br>
00e70000-00e71000 rw-p 00191000 08:01 3806639            /lib/<a href="http://libc-2.12.so" target="_blank">libc-2.12.so</a><br>
00e71000-00e74000 rw-p 00000000 00:00 0<br>
08048000-08049000 r-xp 00000000 08:01 5133928            /tmp/a.out<br>
08049000-0804a000 rw-p 00000000 08:01 5133928            /tmp/a.out<br>
08407000-08428000 rw-p 00000000 00:00 0                  [heap]<br>
f777f000-f7780000 rw-p 00000000 00:00 0<br>
f778d000-f778f000 rw-p 00000000 00:00 0<br>
ffacd000-ffae2000 rw-p 00000000 00:00 0                  [stack]<br>
<br>
( /tmp/a.out is a small program who reads and emits /proc/self/maps)<br>
<div class="HOEnZb"><div class="h5">_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br>