This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


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: Custom section attributes (and more...)


Ciao David,
thanx for your help... I'd probably better to expalin why and what I'm
tryin' to do:

my target is a PowerPc based board and the cross environment is running on
Cygwin.
My software HAS to start from 0x10000 but the vector table on a PPC has to
reside at lower addresses (starting from 0x0); in particular at 0x100
resides the system reset ISR and at 0x500 the external interrupt handler
so...
when I run at 0x10000 I want to buid the exception table. I created a custom
section .vtable and I want to copy its contents; the assembler instructions
are handled correctly, my problems arises when calliing c routines.

here's part of my linker script:
-----------
MEMORY
{
	sram   (rw) :    org = 0x0,       len = 16M
	flash  (rx) :    org = 0x4000000, len = 8M
}

SECTIONS
{
....
.vtable : AT(ADDR(.text)+SIZEOF(.text))
{
	_vtstart = .;
	*(.vtable)
	_vtend = .;
} > sram

...
}

_VT_SIZE = SIZEOF(.vtable);
-------------
this is how I copy the vector table and jump to 0x100:
.globl _makevt

.ORG 0x0
_makevt:
	addis	r3, 0, _vtstart@h
	ori	r3, r3, _vtstart@l

	/* Destination */
	li r4,0x0

	addis	r5, 0, _VT_SIZE@h
	ori	r5, r5, _VT_SIZE@l

	add	r7, r3, r5

cont:
	lwzx	r5, 0, r3
	stwx	r5, 0, r4
	lwzx	r8, 0, r4
	cmp	0, 0, r8, r5

	addi	r4, r4, 4
	addi	r3, r3, 4
	cmp	0, 0, r3, r7
	ble	cont

	/* Set PC */
	lis r4, 0x0
	ori r4, r4, 0x100

	mtlr	r4

	blr
----------------------------------
and here's the custom section:

.section .vtable, "ax"

.org  0x100 /* System Reset - 1st instruction after hw power-on reset. */

	addis   11, 0 , __SP_INIT@h    # Initialize stack pointer r1 to
	addi    1,  11, __SP_INIT@l    # value in linker command file.
	addis   13, 0,  _SDA_BASE_@h   # Initialize r13 to sdata base
	addi    13, 13, _SDA_BASE_@l   # (provided by linker).
	addis   2,  0,  _SDA2_BASE_@h  # Initialize r2 to sdata2 base
	addi    2,  2,  _SDA2_BASE_@l  # (provided by linker).
	addi    0,  0,  0              # Clear r0.

bl      __init_main

.org  0x200
bl isr_dummy200

.org  0x300
bl isr_dummy300

.org  0x400
bl isr_dummy400
.....


Thanx for your time,
Davide


Regards

Davide

--------------.                      ,-.  SS Padana Sup. km 158
Davide Viti    \    ,---------------'   \  I-20060 Cassina de' Pecchi   MI
Siemens ICM/N   `--'                     `--------------------------------



--------------.                      ,-.  SS Padana Sup. km 158
Davide Viti    \    ,---------------'   \  I-20060 Cassina de' Pecchi   MI
Siemens ICM/N   `--'                     `--------------------------------


------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com


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