This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils 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]

Re: Defining a section that isn't file-backed (with an additional wrinkle)


On Wed, Mar 17, 2004 at 12:53:50PM -0500, Ian Lance Taylor wrote:
>Christopher Faylor <cgf@redhat.com> writes:
>
>> I'd like to have a similar type of layout but have the memory reserved
>> but not allocated, i.e., I'd like the OS to set aside the memory addresses
>> automatically but not associate any physical memory with the space until
>> the equivalent of an 'sbrk' is called.
>> 
>> The distinction between reserved and allocated space is probably not a
>> UNIX-like concept although it is easy to do in Windows.  I can't find
>> any way in mmap or sbrk that would allow this, so I am probably out of
>> luck.
>
>It's true that Unix doesn't really distinguish between reserved and
>allocated space.  When you allocate empty space in the program
>segments, Unix doesn't associate any physical memory with that address
>space.  It just marks up the page table entries.  The space is only
>allocated when the program references the page.  You can do a bit of
>tweaking here on some systems with stuff like mlock, the mmap
>MAP_NORESERVE flag, and (on Linux) /proc/sys/vm/overcommit_memory.
>
>>My reason for wanting this is to reserve a guaranteed section of memory
>>in every cygwin process but not necessarily use all of the section --
>>like for a heap.
>>
>>So, is it possible in, ld or gas, to set aside a region of memory as
>>reserved but not allocated?
>
>I guess my question in return is: how do you want to express this?  The
>assembler and linker are only able to express information which can be
>put into the object file.  Does the PE format have a way to express
>this information?

Yes, I should have mentioned this.  In my research on PE format, and of
Microsoft's linker, I'd have to say "no".  But, I suspect that the
available PE documentation on the web isn't complete and I was hopefully
thinking that if ld allowed it, I might be able to work backwards from
source code.

>What you are asking for can more or less be described in a linker
>script using a MEMORY region.  But right now that information won't be
>put into the object file, because Unix object files don't have any
>place for the information to go.

Thanks.  That is what I suspected.

After sending the email, as so often happens, it occurred to me that
there might be another way to do what I want so I'll investigate that.

cgf


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