This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: How to control code segments ?
- From: Dong Phuong <dongphuong2410 at yahoo dot com>
- To: Alan Lehotsky <qsmgmt at earthlink dot net>
- Cc: gcc at gnu dot org
- Date: Sun, 30 Nov 2008 23:14:44 -0800 (PST)
- Subject: Re: How to control code segments ?
"Linker relaxation" is maybe what I'm looking for.
But I've searched it on google , but there are few
doccuments about it, now I haven't imagined yet how to
implement Linker Relaxation.
Could you tell me some of doccuments about it and
where in the binutils that it was implemented ?
--- Alan Lehotsky <qsmgmt@earthlink.net> wrote:
> Look at the implementation of the IP2K compiler and
> linker.
> It uses a segmented paged architecture just like the
> machine you are
> describing.
>
> In essence what we did was implement linker
> relaxation to deal with
> this.
> When we called any function, we emitted the
> appropriate long-call by
> setting
> the page register and jumping to the location on
> that page.
>
> In the linker, we implemented relaxation code that
> looked to see if
> we were changing to the SAME page, and if so deleted
> the instruction
> changing
> the PAGE and did a local jump to the destination.
> Now, because a
> function could cross a page
> boundary (we only had 4kb pages (and 16 bit
> instructions), all our
> branches were done this way
> (if I recall correctly).
>
> It's a little tedious, but not too technically
> demanding a solution....
>
> Al Lehotsky
>
> On Nov 30, 2008, at 2:06 PM, Dong Phuong wrote:
>
> > I'm porting for a microcontroler which has
> segmented
> > memory.
> >
> > THe memory is devided into many pages, each page
> is
> > 16K. And I'm going to use 256 pages for code. But
> > these 256 pages are not continuous in physical
> memory,
> > so when I want to jump to a function, I have to
> know
> > what is the segment address of this function, and
> then
> > set the CSP with this value, and jump to it.
> >
> > So what I want to know is if I'm in a function, is
> > there any way for me to know what code segments
> I'm
> > locating in ? If I know this, when I have to jump
> to
> > another function, I can decide wheather this
> function
> > is in the same segment with the function that I'm
> > locating in, and then can decide if I have to
> change
> > the CSP.
> >
> > And when I compile a long long program with so
> many
> > methods, is there any way for GCC so that it can
> > realize that the code has exceeded 16K and have to
> use
> > a new segments ? or the user must explicit declare
> > this in the C source program ?
> >
> > If you know any hints or any doccument about this,
> > please show me. THank you very much.
> >
> >
> >
>
>