



or32-elf-gcc compile & run
by hwmin75 on Jan 21, 2014 |
hwmin75
Posts: 20 Joined: Mar 8, 2010 Last seen: Jul 21, 2018 |
||
Hello.
I wrote hello2 in C.
void __attribute__((section(".isp"))) hello2(void)
{
printf("hello world \n");
}
also. I wrote a file of ld srcipt in the below(mem.ld)
refer to below
I called hello2 function in main()
int main(void)
{
initHw();
IsrInit();
enx_shell_init();
mtspr(SPR_SR, mfspr(SPR_SR)|SPR_SR_IEE); //enable global irq
timer_tick_init(CPU_CLK,TIME_TICK); //100Hz TIME TICK
timer_init(NULL);
hello2();
}
I disassembled this firmware.
Disassembly of section .isp.text:
b0000000 :
b0000000: d7 e1 4f fc l.sw 0xfffffffc(r1),r9
b0000004: 9c 21 ff fc l.addi r1,r1,0xfffffffc
b0000008: 18 60 00 0e l.movhi r3,0xe
b000000c: 9c 21 00 04 l.addi r1,r1,0x4
b0000010: 85 21 ff fc l.lwz r9,0xfffffffc(r1)
b0000014: 00 00 a8 66 l.j b002a1ac
b0000018: a8 63 0b e4 l.ori r3,r3,0xbe4
00019698 :
19698: d7 e1 4f fc l.sw 0xfffffffc(r1),r9
1969c: d7 e1 17 f8 l.sw 0xfffffff8(r1),r2
196a0: 9c 21 ff ec l.addi r1,r1,0xffffffec
196a4: 07 ff ff b7 l.jal 19580
196a8: 9c 40 00 1e l.addi r2,r0,0x1e
196ac: 04 00 00 cc l.jal 199dc
196b0: 15 00 00 00 l.nop 0x0
196b4: 04 00 0f df l.jal 1d630
196b8: 15 00 00 00 l.nop 0x0
196bc: 07 ff 9f e7 l.jal 1658
196c0: 9c 60 00 11 l.addi r3,r0,0x11
196c4: 9c 60 00 11 l.addi r3,r0,0x11
196c8: 07 ff 9f e1 l.jal 164c
196cc: a8 8b 00 04 l.ori r4,r11,0x4
196d0: 18 60 08 0b l.movhi r3,0x80b
196d4: 9c 80 00 64 l.addi r4,r0,0x64
196d8: 04 00 04 6d l.jal 1a88c
196dc: a8 63 ef c0 l.ori r3,r3,0xefc0
196e0: 04 00 04 c0 l.jal 1a9e0
196e4: 9c 60 00 00 l.addi r3,r0,0x0
196e8: 07 ff 9a 46 l.jal 0
196ec: 15 00 00 00 l.nop 0x0
Disassebled main fucntion called hello2() like above.
196e8: 07 ff 9a 46 l.jal 0
I think that main() should call hello2() with l.jal 0xb0000000
What's wrong ?
I used or32-elf-gcc 4.5.1 rc4.
Thank you.
This file is mem.ld
MEMORY
{
reset : ORIGIN = 0x0000000, LENGTH = 0x1000 /* LENGTH shold not exceed 0x1000 */
emem : ORIGIN = 0x00001000, LENGTH = (0x200000) - 0x1000 /* CPU_SIZE - reset */
ispm : ORIGIN = 0xb0000000, LENGTH = ( 1024)
ram : ORIGIN = 0xb0000000, LENGTH = ( 32*1024) /* RAM0_SIZE */
ram1 : ORIGIN = 0xb1000000, LENGTH = ( 64*1024)
}
SECTIONS
{
.reset :
{
} > reset
.text :
{
*(.text)
*(.rodata)
*(.rodata.*)
} > emem
.isp.text : AT ( (LOADADDR(.text) + SIZEOF(.text) + 3) & ~ (4-1) )
{
__isp_text_s = ALIGN(4);
*(.isp)
__isp_text_e = ALIGN(4);
} > ispm
__rom_isp_text_s = LOADADDR(.isp.text);
__rom_isp_text_e = ( (LOADADDR(.isp.text) + SIZEOF(.isp.text) + 3) & ~ (4-1) ) - LOADADDR(.reset);
.data : AT ( (LOADADDR(.isp.text) + SIZEOF(.isp.text) + 3) & ~ (4-1) )
{
__data_s = ALIGN(4);
*(.data)
*(.data.rel)
*(.data.rel.local)
*(.sdata)
__data_e = ALIGN(4);
} > emem
__rom_data_s = LOADADDR(.data);
__rom_data_e = ( (LOADADDR(.data) + SIZEOF(.data) + 3) & ~ (4-1) ) - LOADADDR(.reset);
.bss (NOLOAD) :
{
__bss_s = ALIGN(4);
*(.bss) *(COMMON)
__bss_e = ALIGN(4);
} > emem
__end = .;
__except_stack = (0xb0000000+64*1024-4);
__isr_stack = (0xb0000000+32*1024-4);/*__except_stack - 16*1024;*/
.stack (0xb1000000 + 64*1024-4) (NOLOAD) : /* RAM0_BASE + RAM0_SIZE - 4 */
{
__stack = .;
*(._stack)
}
}
|
RE: or32-elf-gcc compile & run
by hwmin75 on Jan 21, 2014 |
hwmin75
Posts: 20 Joined: Mar 8, 2010 Last seen: Jul 21, 2018 |
||
Hello.
I wrote hello2 in C.
void __attribute__((section(".isp"))) hello2(void)
{
printf("hello world \n");
}
also. I wrote a file of ld srcipt in the below(mem.ld)
refer to below
I called hello2 function in main()
int main(void)
{
initHw();
IsrInit();
enx_shell_init();
mtspr(SPR_SR, mfspr(SPR_SR)|SPR_SR_IEE); //enable global irq
timer_tick_init(CPU_CLK,TIME_TICK); //100Hz TIME TICK
timer_init(NULL);
hello2();
...
}
I disassembled this firmware.
Disassembly of section .isp.text:
b0000000 :
b0000000: d7 e1 4f fc l.sw 0xfffffffc(r1),r9
b0000004: 9c 21 ff fc l.addi r1,r1,0xfffffffc
b0000008: 18 60 00 0e l.movhi r3,0xe
b000000c: 9c 21 00 04 l.addi r1,r1,0x4
b0000010: 85 21 ff fc l.lwz r9,0xfffffffc(r1)
b0000014: 00 00 a8 66 l.j b002a1ac
b0000018: a8 63 0b e4 l.ori r3,r3,0xbe4
00019698 :
19698: d7 e1 4f fc l.sw 0xfffffffc(r1),r9
1969c: d7 e1 17 f8 l.sw 0xfffffff8(r1),r2
196a0: 9c 21 ff ec l.addi r1,r1,0xffffffec
196a4: 07 ff ff b7 l.jal 19580
196a8: 9c 40 00 1e l.addi r2,r0,0x1e
196ac: 04 00 00 cc l.jal 199dc
196b0: 15 00 00 00 l.nop 0x0
196b4: 04 00 0f df l.jal 1d630
196b8: 15 00 00 00 l.nop 0x0
196bc: 07 ff 9f e7 l.jal 1658
196c0: 9c 60 00 11 l.addi r3,r0,0x11
196c4: 9c 60 00 11 l.addi r3,r0,0x11
196c8: 07 ff 9f e1 l.jal 164c
196cc: a8 8b 00 04 l.ori r4,r11,0x4
196d0: 18 60 08 0b l.movhi r3,0x80b
196d4: 9c 80 00 64 l.addi r4,r0,0x64
196d8: 04 00 04 6d l.jal 1a88c
196dc: a8 63 ef c0 l.ori r3,r3,0xefc0
196e0: 04 00 04 c0 l.jal 1a9e0
196e4: 9c 60 00 00 l.addi r3,r0,0x0
196e8: 07 ff 9a 46 l.jal 0
196ec: 15 00 00 00 l.nop 0x0
Disassebled main fucntion called hello2() like above.
196e8: 07 ff 9a 46 l.jal 0
I think that main() should call hello2() with l.jal 0xb0000000
What's wrong ?
I used or32-elf-gcc 4.5.1 rc4.
Thank you.
This file is mem.ld
MEMORY
{
reset : ORIGIN = 0x0000000, LENGTH = 0x1000 /* LENGTH shold not exceed 0x1000 */
emem : ORIGIN = 0x00001000, LENGTH = (0x200000) - 0x1000 /* CPU_SIZE - reset */
ispm : ORIGIN = 0xb0000000, LENGTH = ( 1024)
ram : ORIGIN = 0xb0000000, LENGTH = ( 32*1024) /* RAM0_SIZE */
ram1 : ORIGIN = 0xb1000000, LENGTH = ( 64*1024)
}
SECTIONS
{
.reset :
{
} > reset
.text :
{
*(.text)
*(.rodata)
*(.rodata.*)
} > emem
.isp.text : AT ( (LOADADDR(.text) + SIZEOF(.text) + 3) & ~ (4-1) )
{
__isp_text_s = ALIGN(4);
*(.isp)
__isp_text_e = ALIGN(4);
} > ispm
__rom_isp_text_s = LOADADDR(.isp.text);
__rom_isp_text_e = ( (LOADADDR(.isp.text) + SIZEOF(.isp.text) + 3) & ~ (4-1) ) - LOADADDR(.reset);
.data : AT ( (LOADADDR(.isp.text) + SIZEOF(.isp.text) + 3) & ~ (4-1) )
{
__data_s = ALIGN(4);
*(.data)
*(.data.rel)
*(.data.rel.local)
*(.sdata)
__data_e = ALIGN(4);
} > emem
__rom_data_s = LOADADDR(.data);
__rom_data_e = ( (LOADADDR(.data) + SIZEOF(.data) + 3) & ~ (4-1) ) - LOADADDR(.reset);
.bss (NOLOAD) :
{
__bss_s = ALIGN(4);
*(.bss) *(COMMON)
__bss_e = ALIGN(4);
} > emem
__end = .;
__except_stack = (0xb0000000+64*1024-4);
__isr_stack = (0xb0000000+32*1024-4);/*__except_stack - 16*1024;*/
.stack (0xb1000000 + 64*1024-4) (NOLOAD) : /* RAM0_BASE + RAM0_SIZE - 4 */
{
__stack = .;
*(._stack)
}
}
|
RE: or32-elf-gcc compile & run
by hwmin75 on Jan 21, 2014 |
hwmin75
Posts: 20 Joined: Mar 8, 2010 Last seen: Jul 21, 2018 |
||
I'm sorry. Editing is not easy.
|



