This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Segment mapped with incorrect permissions


Hi,

I have a binary in which a new section is defined and mapped to a
specific address. Here are the relevant sections of the (GNU) linker
script:

MEMORY
{
 	before (rxai) : ORIGIN =   0x000400, LENGTH = 0x400000 /* 0x400 is room for program headers */
 	loadarea      : ORIGIN =   0x400000, LENGTH = 256M
        after (rxai)  : ORIGIN = 0x10400000, LENGTH = 0xe0c00000
}

.....

  /* WINE: reserve PE load area */
  .wine.loadarea : { KEEP (*(.wine.loadarea)) } >loadarea :loadarea

This is how the section is defined in the source file:

asm("\t.section .wine.loadarea, \"a\", @nobits\n");
asm("\t.zero 0x10000000\n"); /* 256mb allocation */

and here is the relevant output of objdump:

   LOAD off    0x00001000 vaddr 0x00400000 paddr 0x00400000 align 2**12
        filesz 0x00000000 memsz 0x10000000 flags r--

As you can see, the segment has read-only permissions.

However, reading /proc/self/maps from within the process shows this:

00400000-10421000 rwxp 00000000 00:00 0

ie the load area has been mapped with PROT_READ|PROT_WRITE|PROT_EXEC, which 
is not what I am trying to achieve.

The relevant part of the glibc 2.3.2 code seems to be elf/dl-load.c:926.
I can easily understand the unoptimized path but I can't figure out the
optimized case. However, unless I've made a fundamental mistake somewhere, 
I can't understand why the rtld is mapping this segment with the wrong 
permissions. I've asked on the binutils list and they seem to be stumped too.

Does anybody have some ideas of what might be going wrong here?

thanks -mike


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]