Page 1 of 1
Linker script rodata
Posted: Sun Mar 09, 2008 10:36 pm
by piranha
Does anybody have a sample linker script that keeps rodata?
I need to link a simple C file against my library and have the out format be binary.
Thanks, JL
Posted: Mon Mar 10, 2008 1:15 am
by Solar
Try linker.ld from the
Bare Bones tutorial.
Posted: Mon Mar 10, 2008 4:53 pm
by piranha
Well, my kernel simply loads the binary into memory and jumps to it.
With this code and the Bare Bones script:
Code: Select all
char b[16];
b[0] = 'S';
b[1] = 'y';
b[2] = 'n';
b[3] = 'c';
b[4] = 'i';
b[5] = 'n';
b[6] = 'g';
b[7] = '\n';
b[8] = '\0';
kputs(b);
kputs("fine");
I get:
And thats it.
It should say 'fine'....Do you need any more info?
-JL
Posted: Mon Mar 10, 2008 9:28 pm
by ucosty
Objdump your executable and make sure the data is really in there. Dissassemble the relevant source and make sure it is pointing to your rodata section.
Posted: Mon Mar 10, 2008 9:55 pm
by piranha
Objdump output (when I compile it to an elf):
Code: Select all
Disassembly of section .rodata:
00101000 <_ebss-0x18>:
101000: 66 69 6e 65 00 2e imul $0x2e00,0x65(%esi),%bp
101006: 2e 2e 00 77 6f add %dh,%cs:0x6f(%edi)
10100b: 72 6b jb 101078 <_ebss+0x60>
10100d: 3f aas
10100e: 00 57 61 add %dl,0x61(%edi)
101011: 69 .byte 0x69
101012: 74 2e je 101042 <_ebss+0x2a>
101014: 2e cs
101015: 2e cs
...
So it looks like it's there...Edit: Is the actual data there?
Heres a newer one:
Code: Select all
char b[16];
b[0] = 'S';
b[1] = 'y';
b[2] = 'n';
b[3] = 'c';
b[4] = 'i';
b[5] = 'n';
b[6] = 'g';
b[7] = '\n';
b[8] = '\0';
kputs(b);
char c[16] = "Hello!\0";
kputs(c);
Goes to
Code: Select all
Disassembly of section .rodata:
08048103 <.rodata>:
8048103: 48 dec %eax
8048104: 65 gs
8048105: 6c insb (%dx),%es:(%edi)
8048106: 6c insb (%dx),%es:(%edi)
8048107: 6f outsl %ds:(%esi),(%dx)
8048108: 21 00 and %eax,(%eax)
-JL