This is the mail archive of the binutils@sourceware.cygnus.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]

Linking and Loading differently




Hi,

I have an issue with the --gstabs option.
I have attached the test files and the script file. When I try debugging
it, by inserting a breakpoint at main, it points main to a wrong address
and line number. The line number information is not correct.
The reason is that if the files are linked in one order and the linker
script specifies a different order to store these sections, in the
executable, the stabs information is not correct.

Thanks,
meena





/***********************************************************************

* NAME: test.c

*

* DESCRIPTION: Test of user interrput vector table operation

*

* AUTHOR: RA Kocot

*

* PROCESSING:

*

* IMPLEMENTATION NOTES: Link with interrupt vector table using script

*

* PLATFORM: EB401

************************************************************************/





/*

* Variable is incremented by the timer isr defined in “vectors.s”

*/



extern int Timer0_Sem;



/*

* References to utilities defined in “util.s”

*/



extern void timer_enable(int id);

extern void timer_set(int id, unsigned value);

extern unsigned timer_read(int id);

extern void timer_mode(int id, int reload);

extern void timer_prescale(int id, unsigned prescale);

void led_write(int fourbits);



/*

* Assembly macro for enabling user interrupt vector table

*/



#define USE_IVT0 asm("bits %smode, 7");



/*

* Assembly macros for controlling interrupt mask bits

*/



#define USE_INT0 asm("bits %imask, 0");

#define USE_TIMER0 asm("bits %imask, 5");



/*

* Definition of timer ID values for passing to utility calls

*/



#define TIMER_0 0

#define TIMER_1 1



/*

* Definition of timer modes for passing to utility calls

*/



#define TIMER_MODE_RELOAD 1

#define TIMER_MODE_SINGLE 0



/*

* Definition of Timer parameters for this test

*/



#define TIMER_RELOAD 0x0ffff /* timer counts down/reloads this number at 0 */

#define TIMER_DIVIDER 0x01 /* processor clock divider (1-64) */

#define TIMER_ISR_OVERHEAD_CYCLES 17

#define STOP_TIME 0x0FFFF /* arbitrary count to stop on */





void main()

{

	unsigned cycles_msw;

	unsigned cycles_lsw;

	unsigned isr_cycles;

	int high_t;



	/*

	* set interrupt vector table to internal memory at address 0

	*/



	USE_IVT0



	/*

	* initialize the isr variable

	*/



	Timer0_Sem = 0;



	/*

	* initialize the cycle count msw

	*/





     cycles_msw = 0;



	/*

	* set up timer0

	*/



   timer_mode(TIMER_0,TIMER_MODE_RELOAD); /* set timer auto-reload mode */

	timer_prescale(TIMER_0,TIMER_DIVIDER - 1 ); /* set divide clock for timer0 */

	timer_set(TIMER_0,TIMER_RELOAD); /* set timer reload value */

	timer_enable(TIMER_0); /* enable timer0 in tc register */



	/*

	* Use MACRO to set timer0 bit in imask register

	*/



   USE_TIMER0



   for(;;)

	  {

	  /* wait for the interrupt to update the variable */

	  if(Timer0_Sem != cycles_msw)

			{

			/* Update the cycle count */

			cycles_msw = Timer0_Sem;



         /* show upper four bits on leds */

			led_write( ( cycles_msw >> 12 ) & 0x0F );



			/* stop at STOP_TIME */

			if(Timer0_Sem == STOP_TIME)

				{

				/* example finished - collect test statistics */

				cycles_lsw = TIMER_RELOAD - timer_read(TIMER_0);

				isr_cycles = cycles_msw * TIMER_ISR_OVERHEAD_CYCLES;

				cycles_msw /= ( TIMER_DIVIDER );



				for(;;) {}  /* stop - set breakpoint here */

			 	}

			}

		}

}











/*!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

! C DECLARATION: void led_write(int fourbits)

!

! INPUT PARAMETER: fourbits 4-bit LED value

!

! RETURN VALUE: none

!

! PROCESSING: Mask input parameter for valid four bits

! Enable All 4 PIOs as outputs

! Invert the four bits to cause a '1' to

!

! illuminate the LED illuminate the LED

!

! TARGET: EB401

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/









void led_write(int fourbits)

{



	

	volatile unsigned int *PIO_REG = (volatile unsigned int *) 0xe806;



	 /*limit to four leds and enable output, display ones as light on */

	*PIO_REG = (fourbits & 0x000f) ^ 0x000f;	 



}



!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

! NAME: vectors.s 

!

! DESCRIPTION: User's Interrupt Vector Table Example 

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!

! AUTHOR: RA Kocot ! AUTHOR: RA Kocot

!

! DATE: October 18, 1999 ! DATE: October 18, 1999

!

! IMPLEMENTATION NOTES: Assemble this program to an object file

! to link with your application code

!

!     assemble sdas -o vectors.obj vectors.s 

!     link sdld -Tvector.scr myprogram.obj 

!

!     contents of vector.scr

!

!     SECTIONS { 

!                vectors (0x0000) : {vectors.o} 

!              }

!

!     To remap interrupt vectors from the default 0xf800 

!     set uvt bit in smode register and begin using this code 

!

!     Timer 0 Interrupt Service 

!     The file 'data.s' contains the declaration for _Timer0_Sem that is 

!      incremented by the Timer 0 ISR 

!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 





	.section "vectors", "ax"



	.global _isr_nmi, _isr_dei, _isr_hir, _isr_hit

	.global _isr_s1r, _isr_s1t, _isr_s0r, _isr_s0t, _isr_dma

	.global _isr_t1, _isr_t0, _isr_ex4, _isr_int4

	.global _isr_ex3, _isr_ex2, _isr_ex1, _isr_ex0 



	.global Timer0_Sem 

	.global _Timer0_Sem 





.wspace 8

.walign 8

_isr_nmi:      br  process_spurious



.walign 8

_isr_dei:      br -0x800                            ! use the JTAG ISR from the boot section



.walign 8

_isr_hir:      br   process_spurious 



.walign 8

_isr_hit:      br    process_spurious 



.walign 8

_isr_s1r:      br   process_spurious



.walign 8

_isr_s1t:      br   process_spurious 



.walign 8

_isr_s0r:      br   process_spurious



.walign 8

_isr_s0t:      br    process_spurious





.walign 8

_isr_dma:      br     process_spurious



.walign 8

_isr_t1:       br    process_spurious



.walign 8

_isr_t0:       br    process_t0      ! Use the TIMER 0 ISR from this module



.walign 8

_isr_ex4:      br   -0x800           ! Use the UART ISR from the boot section



.walign 8

_isr_ex3:      br    process_spurious



.walign 8

_isr_ex2:      br    process_spurious



.walign 8

_isr_ex1:      br    process_spurious



.walign 8

_isr_ex0:      br    process_spurious









/*****************************************************************



  timer interrupt routine



  incremets   _Timer0_Sem counter



*****************************************************************/





.walign 8

process_t0:

	stu    r3, r12, -1      	! push r3

	stu    r13, r12, -1     	! push r13 (only necessary for isrs)

 	lda r13, _Timer0_Sem     	! load address of timer interrupt counter

	ld 	r3, r13 		    	! use r13 for value r3, r13

	add 	r3, 1 				! increment timer

	st 	r3, r13 			    ! save timer interrupt counter



	add     r12,1

	ldu 	r13, r12, +1 		! pop r13 (only necessary for isrs)

	ld 	    r3, r12  			! pop r3

	reti



process_spurious: 			! ERROR - an unexpected/unhandled interrupt occurred

	reti








	.section ".data"

_Timer0_Sem:   .word   0

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

! NAME: util.s

!

! DESCRIPTION: C-Callable Assembly routines for timer management

!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!

! AUTHOR: RA Kocot

!

! DATE: October 18, 1999

!

! IMPLEMENTATION NOTES:

!

! TARGET: EB401

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!



	!.segment "text"

    .section .text



!	.xdef _led_write

	.xdef _timer_enable



   .xdef _timer_mode

	.xdef _timer_prescale

	.xdef _timer_set

	.xdef _timer_read

	.xdef __end





!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

! C DECLARATION: void write_timer_control(unsigned bits16)

!

! INPUT PARAMETER: r4 timer control register

!

! RETURN VALUE: none

!

! PROCESSING: Write value passed in r4 to the %tc timer control register

!

! TARGET: LSI401Z

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!



			.walign 2

_write_timer_control:

			mov %tc, r4

			ret



!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

! C DECLARATION: void timer_enable(int id);

!

! INPUT PARAMETER: r4 timer id (timer0 = 0, timer1 = 1)

!

! RETURN VALUE: none

!

! PROCESSING: set enable bit in timer control register

!

! TARGET: LSI401Z

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!



			.walign 2

_timer_enable:

			bitt 	r4, 0



timer_enable_1:

			bz 	timer_enable_0

			bits 	%tc, 15

			ret



timer_enable_0:

			bits %tc, 7

			ret



!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

! C DECLARATION: void timer_mode(int id, int reload);

!

! INPUT PARAMETERS: r4 timer id (timer0 = 0, timer1 = 1)

! r5 0 = single shot, 1 = auto-reload

!

! RETURN VALUE: none

!

! PROCESSING: set timer mode in timer control register

!

! TARGET: LSI401Z

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!



			.walign 2

_timer_mode:  	bitt 	r4, 0

					bz 	timer_0_mode

timer_1_mode: 	bitt 	r5, 0

					bz 	timer_1_ss

timer_1_reload:

					bits 	%tc, 14

					ret

timer_1_ss: 	bitc	%tc, 14

					ret

timer_0_mode:  bitt	r5, 0

					bz 	timer_0_ss

timer_0_reload:

					bits %tc, 6

					ret

timer_0_ss:

					bitc %tc, 6

					ret



!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

! C DECLARATION: void timer_prescale(int id, unsigned prescale);

!

! INPUT PARAMETERS: r4 timer id (timer0 = 0, timer1 = 1)

! r5 prescale value n for use as 2^n

!

! RETURN VALUE: none

!

! PROCESSING: set timer prescale value in timer control register

!

! TARGET: LSI401Z

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!



					.walign 2

_timer_prescale: 	bitt 	r4, 0

						bz 	timer_0_prescale

timer_1_prescale: mov 	r13, %tc

						mov 	r6, 0x0C0FF

						and 	r13, r6

						shll 	r4, 8

						or 	r13, r4

						mov 	%tc, r13

						ret



timer_0_prescale: mov 	r13, %tc

						mov 	r6, 0x0FFC0

						and 	r13, r6

						or 	r13, r4

						mov 	%tc, r13

						ret



!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

! C DECLARATION: void timer_set(int id, unsigned value);

!

! INPUT PARAMETERS: r4 timer id (timer0 = 0, timer1 = 1)

! r5 Timer Countdown Value

!

! RETURN VALUE: none

!

! PROCESSING: set timer to Countdown Value in timer register

! (this value will be reloaded at terminal count

! in auto-reload mode)

!

! TARGET: LSI401Z

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!



					   .walign 2

_timer_set: 		bitt 	r4, 0

						bz 	timer_0_set

						mov 	%timer1, r5

						ret

timer_0_set: 		mov 	%timer0, r5

						ret



!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

! C DECLARATION: unsigned timer_read(int id);

!

! INPUT PARAMETERS: r4 timer id (timer0 = 0, timer1 = 1)

!

! RETURN VALUE: Timer Value

!

! PROCESSING: read timer and return value

!

! TARGET: LSI401Z

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!



					.walign 2

_timer_read: 		bitt 	r4,0

						bz 	timer_0_read

						mov 	r4, %timer1

						ret

timer_0_read: 		mov 	r4, %timer0

						ret

						nop

						nop

						nop







#!/bin/csh -f
sdcc -g -v -o test1.exe -Wa,-dbg -Wl,-Tld.src.lnk  test.c util.s vectors.s

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