need help with section attributes & relocation

Robin Kirkham Robin.Kirkham@mlb.dmt.csiro.au
Wed Sep 10 07:27:00 GMT 1997


> From: "Ken Greenberg" <ken@calast.com>
> Message-Id: < 199709091836.AA06460@tango.rahul.net >
> Date: Tue, 9 Sep 1997 11:31:39 -0700
>
> I am running a SunOS-hosted cross development environment for MIPS 
> that I built successfully a while ago. Now I am trying to write some 
> small tests that need to locate code in kseg1 (0xa000000), and I have 
> tried innumerable approaches to actually getting a section of code 
> located there with the proper attributes. I am tired of fighting with 
> the linker command language, so this seems like a good time to ask 
> for help.
> ...

Ken, 

I use linker scripts and named sections (i.e., other than .text, .data
and .bss) to put things in the locations I want. For instance, I put the
68k vector table in a section called .evec, variables that should go in an
SRAM segment in a section called .sram, and so on. This has to be done in
assembler. Then, I use the MEMORY thing in the linker script to define the
blocks of memory, including the base address and size of the block, and 
feed it into the block I want, using something essentially like

    MEMORY {
	evec: 0x0 len 0x1000
	ram: 0x1000 len 1M-0x1000
	sram: 0xc00000 len 16k
    }
    ...
    .evec { *(.evec) } > evec
    .sram { *(.sram) } > sram

(there is obviously other stuff and the syntax is probably wrong but I can't
access my sources right now).  This works quite nicely for me for 68k-coff,
although it's generally items of data that I deal with that way, not text.

I have had trouble with defining section attributes, however: I wanted to
define NOLOAD for something a while ago but I couldn't get it to work.
It could be there is a problem there: eventually gave up too. The linker
language is a strange beast.

Robin Kirkham			CSIRO Manufacturing Science and Technology
Project Engineer		Locked Bag 9, Preston 3072, Australia
robin.kirkham@mlb.dmt.csiro.au	Phone: +61 3 9662-7756  Fax: +61 3 9662-7851



More information about the crossgcc mailing list