Page 2 of 2
Re: C arrays
Posted: Tue Nov 19, 2013 3:07 pm
by AbstractYouShudNow
My gcc adds some functions during compilaion it seems...
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.
Re: C arrays
Posted: Tue Jan 07, 2014 2:46 pm
by teodori
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:
const uint8_t test[] = "xyz";
vga_write(VGA_BLACK, VGA_LIGHT_CYAN, test, 3, 1);
2:
vga_write(VGA_BLACK, VGA_LIGHT_CYAN, "abc", 3, 1);
LD script
Code: Select all
OUTPUT(kernel.img)
OUTPUT_FORMAT(binary)
ENTRY(start)
SECTIONS{
.text : { *(.text) }
.rodata : { *(.rodata) }
.data : { *(.data) }
.bss : { *(.bss) }
.eh_frame : { *(.eh_frame) }
}
Re: C arrays
Posted: Tue Jan 07, 2014 3:40 pm
by Owen
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.
Re: C arrays
Posted: Tue Jan 14, 2014 5:36 pm
by teodori
Ok found out what caused the problem. It was during the linking process. I corrected my linker script, now it works.
Thank you.