I encountered something strange, and I wonder if it's a bug or a feature.
This is a simple test code which I use as a kernel to test my loader.
Code: Select all
#include <cpp_support.h>
char* const vmem = (char *) 0xb8000;
char* vmem2 = (char *) 0xb8000;
int vmem3;
const char notes = 0x0e;
class Truc {
public:
Truc();
char toto;
};
Truc::Truc():
toto(notes)
{
vmem[0]='O';
}
Truc mon_truc;
extern "C" int kmain() {
//Okay, everything is ready
vmem[2] = 'K';
vmem2[4] = '!';
vmem2[6] = mon_truc.toto;
vmem3 = mon_truc.toto;
return 0;
}
Code: Select all
Section Headers:
[Nr] Name Type Address Offset
Size EntSize Flags Link Info Align
[ 0] NULL 0000000000000000 00000000
0000000000000000 0000000000000000 0 0 0
[ 1] .text PROGBITS 0000000000000000 00000040
0000000000000160 0000000000000000 AX 0 0 4
[ 2] .rela.text RELA 0000000000000000 00000910
0000000000000210 0000000000000018 12 1 8
[ 3] .data PROGBITS 0000000000000000 000001a0
0000000000000008 0000000000000000 WA 0 0 8
[ 4] .bss NOBITS 0000000000000000 000001a8
0000000000000005 0000000000000000 WA 0 0 4
[ 5] .rodata PROGBITS 0000000000000000 000001a8
0000000000000009 0000000000000000 A 0 0 8
[ 6] .ctors PROGBITS 0000000000000000 000001b8
0000000000000008 0000000000000000 WA 0 0 8
[ 7] .rela.ctors RELA 0000000000000000 00000b20
0000000000000018 0000000000000018 12 6 8
[ 8] .comment PROGBITS 0000000000000000 000001c0
0000000000000012 0000000000000001 MS 0 0 1
[ 9] .eh_frame PROGBITS 0000000000000000 000001d8
00000000000000a8 0000000000000000 A 0 0 8
[10] .rela.eh_frame RELA 0000000000000000 00000b38
0000000000000078 0000000000000018 12 9 8
[11] .shstrtab STRTAB 0000000000000000 00000280
000000000000005d 0000000000000000 0 0 1
[12] .symtab SYMTAB 0000000000000000 00000660
00000000000001f8 0000000000000018 13 13 8
[13] .strtab STRTAB 0000000000000000 00000858
00000000000000b8 0000000000000000 0 0 1
Code: Select all
Section Headers:
[Nr] Name Type Address Offset
Size EntSize Flags Link Info Align
[ 0] NULL 0000000000000000 00000000
0000000000000000 0000000000000000 0 0 0
[ 1] .text PROGBITS 0000000000000000 00000040
0000000000000119 0000000000000000 AX 0 0 16
[ 2] .rela.text RELA 0000000000000000 00000798
00000000000001b0 0000000000000018 11 1 8
[ 3] .data PROGBITS 0000000000000000 00000160
0000000000000008 0000000000000000 WA 0 0 8
[ 4] .bss NOBITS 0000000000000000 00000168
0000000000000005 0000000000000000 WA 0 0 4
[ 5] .ctors PROGBITS 0000000000000000 00000168
0000000000000008 0000000000000000 WA 0 0 8
[ 6] .rela.ctors RELA 0000000000000000 00000948
0000000000000018 0000000000000018 11 5 8
[ 7] .comment PROGBITS 0000000000000000 00000170
0000000000000012 0000000000000001 MS 0 0 1
[ 8] .eh_frame PROGBITS 0000000000000000 00000188
0000000000000068 0000000000000000 A 0 0 8
[ 9] .rela.eh_frame RELA 0000000000000000 00000960
0000000000000060 0000000000000018 11 8 8
[10] .shstrtab STRTAB 0000000000000000 000001f0
0000000000000055 0000000000000000 0 0 1
[11] .symtab SYMTAB 0000000000000000 00000588
0000000000000198 0000000000000018 12 9 8
[12] .strtab STRTAB 0000000000000000 00000720
0000000000000075 0000000000000000 0 0 1