On Thu, Feb 14, 2013 at 4:19 PM, Jakub Jelinek <ja...@redhat.com> wrote: > On Thu, Feb 14, 2013 at 03:55:47PM +0400, Konstantin Serebryany wrote: >> The patch seems to work on a simple test. Let me digest it. >> I am trying to understand if there are problems with it other than the >> added complexity (which is what I don't like the most). > > Yes, it is some added complexity, but not too much, and something that can > be tested regularly that it works.
The complexity I am afraid of is not only in the code, but also at the time of execution. We and our users sometimes have to stare at the /proc/self/maps. A mapping with 1 (ZeroBase) or 3 (default) asan sections is ok, but 6 extra asan sections becomes nearly incomprehensible, at least for me. So, how about having kMidMemBeg as a variable, set as __asan_init. Only if something is mapped around 0x003X00000000 we set it to non-zero. http://llvm-reviews.chandlerc.com/D411 (still needs some cleanup) Unfortunately, the test does not work if gold is the system linker. Any suggestion on how to make the test work with either linker? Thanks, --kcc > >> -Wl,-Ttext-segment=0x3600000000 does not work with binutils-gold. >> gold understands -Wl,-Ttext=0x3600000000, but bfd ld doesn't. >> Do you know any flag supported by both? > > -Wl,-Ttext is unfortunately something different, at least for > the bfd linker. -Ttext-segment aligns the base of the whole shared library, > if you look at start of the linker script for -shared: > /* Read-only sections, merged into text segment: */ > . = SEGMENT_START("text-segment", 0) + SIZEOF_HEADERS; > .note.gnu.build-id : { *(.note.gnu.build-id) } > .hash : { *(.hash) } > .gnu.hash : { *(.gnu.hash) } > .dynsym : { *(.dynsym) } > .dynstr : { *(.dynstr) } > .gnu.version : { *(.gnu.version) } > .gnu.version_d : { *(.gnu.version_d) } > .gnu.version_r : { *(.gnu.version_r) } > ... > .rela.plt : > { > *(.rela.plt) > *(.rela.iplt) > } > .init : > { > KEEP (*(.init)) > } > .plt : { *(.plt) *(.iplt) } > .text : > { > *(.text.unlikely .text.*_unlikely) > *(.text.exit .text.exit.*) > -Ttext-segment chooses the base at which ELF headers will reside. > -Ttext aligns the .text section's start to that, so most likely the shared > library won't even link, because .init section will be many GBs appart from > .text section. > > CCing Ian, if gold has any way to do something similar. > As I said, the alternative is to link the library normally, and run > prelink -r 0x3600000000 libtest.so on the shared library afterwards if > prelink is > installed, and make sure you install it on your linux/x86-64 test boxes. > > Jakub