From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <5e571fa65ee3c57240eec513554d9eba@plan9.bell-labs.com> Date: Tue, 31 Jan 2006 00:48:03 -0500 From: jmk@plan9.bell-labs.com To: 9fans@cse.psu.edu Subject: Re: [9fans] Data segment vs BSS In-Reply-To: <56a297000601302135j778614c3r1ba9751ffa557cff@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Topicbox-Message-UUID: ecbd36e6-ead0-11e9-9d60-3106f5b1d025 The part of the loader for this is not dificult to understand. Grep for HEADTYPE in the source, only asm.c and obj.c will likely come up, and in each only one function: obj.c:main() sets up the variables that say where the virtual addresses of the sections are and asm.c:asmb() seeks around using those values for the different header types and writes the stuff out. Usually the data section has 2 types of data in it, constant data and data that can be modiied by the programme, how are you planning to separate those out? Many years ago when I did the boot ROM for the Hobbit boards I just copied the data to real memory so there was no issue like this. How big is your data segment, big enough to worry about using up RAM? On Tue Jan 31 00:36:11 EST 2006, noah.evans@gmail.com wrote: > Hmmmmm... it will require a lot of work understanding the linker, but > if I end up running out of memory, I might see if I can get the const > keyword to throw those variables in the text section and avoid the > problem altogether. > > What do you think? > > Noah > > > > On 1/31/06, jmk@plan9.bell-labs.com wrote: > > The normal Plan 9 binary format assumes the BSS starts immediately > > after the data, there is no place in the header to specify otherwise. > > So, you want to use a different header format, e.g. ELF or one of > > the machine-specific boot formats, see /sys/src/cmd/?l/asm.c for > > examples. There may be one there already that suits, or you can easily > > add another for your particular environment. > > > > But how do you separate out the constant data? > > > > On Mon Jan 30 23:36:55 EST 2006, noah.evans@gmail.com wrote: > > > Hey, quick 2l question. Is there any way to keep constant values in > > > ROM? If possible I'd like to keep the data section entirely in ROM > > > and only keep the BSS section in RAM. However, both sections seem to > > > be inextricably linked. > > > > > > What's the proper way to deal with this? > > > > > > Noah > >