Consider reading about GCC Stack Smashing Protector on the wiki, most particularly its section 1.3, that should explain your problem, and ell you how to solve it.My gcc adds some functions during compilaion it seems...
C arrays
-
- Member
- Posts: 92
- Joined: Tue Aug 14, 2012 8:51 am
Re: C arrays
Re: C arrays
No problem is the linking process. In the first case the string is accessed using local offsets and in the .text zone. In the second case the string is accessed using physical addresses and in the .rodata zone. The problem is the linker script...
1:
1:
2:const uint8_t test[] = "xyz";
vga_write(VGA_BLACK, VGA_LIGHT_CYAN, test, 3, 1);
LD scriptvga_write(VGA_BLACK, VGA_LIGHT_CYAN, "abc", 3, 1);
Code: Select all
OUTPUT(kernel.img)
OUTPUT_FORMAT(binary)
ENTRY(start)
SECTIONS{
.text : { *(.text) }
.rodata : { *(.rodata) }
.data : { *(.data) }
.bss : { *(.bss) }
.eh_frame : { *(.eh_frame) }
}
- Owen
- Member
- Posts: 1700
- Joined: Fri Jun 13, 2008 3:21 pm
- Location: Cambridge, United Kingdom
- Contact:
Re: C arrays
You want *(.text*) and co for a start (GCC will emit symbols in sections like .text.foo, .data.bar, .bss.baz).
You're also missing *(COMMON), for common symbols from the common pseudo-section (they should go into BSS)
Also, you're outputting to binary yet I don't see any address information anywhere.
You're also missing *(COMMON), for common symbols from the common pseudo-section (they should go into BSS)
Also, you're outputting to binary yet I don't see any address information anywhere.
Re: C arrays
Ok found out what caused the problem. It was during the linking process. I corrected my linker script, now it works.
Thank you.
Thank you.