OSDev.org https://forum.osdev.org/ |
|
(SOLVED) GCC ignoring __attribute__((section(xxx))) https://forum.osdev.org/viewtopic.php?f=13&t=32636 |
Page 1 of 1 |
Author: | tongko [ Sat Dec 16, 2017 7:43 am ] |
Post subject: | (SOLVED) GCC ignoring __attribute__((section(xxx))) |
Hi, I've been compiling same code for a while until I added few more code files and header files, then out of sudden GCC just ignoring the __attribute__((section(xxx))) and throw all my function under .text section. Does anyone ever encounter such bazaar behavior of GCC? shortcut definition Code: #ifndef __sect #define __sect(S) __attribute__((section(#S))) #endif #define __early __sect(.early) #define __earlydata __sect(.earlydata) header file Code: #ifndef __PAGING_H_ #define __PAGING_H_ #include <stddef.h> #include "../ktypedef.h" #define ENTRY_MASK 0xFFFFFFFFFF000UL // 1111 1111 1111 1111 1111 1111 1111 1111 1111 1111 0000 0000 0000 #define PDPTR_MASK 0xC0000000 // 1100 0000 0000 0000 0000 0000 0000 0000 #define PD_MASK 0x3FE00000 // 0011 1111 1110 0000 0000 0000 0000 0000 #define PT_MASK 0x001FF000 // 0000 0000 0001 1111 1111 0000 0000 0000 #define PO_MASK 0x00000FFF // 0000 0000 0000 0000 0000 1111 1111 1111 #define PAGE_SIZE 0x00001000 // 4 KIB #define ENTRY_SIZE 0x00000200 // 512 entries #define PT_SIZE_IN_BYTE (ENTRY_SIZE * sizeof(uint64_t)) #define PD_SIZE_IN_BYTE (ENTRY_SIZE * PT_SIZE_IN_BYTE) #define KERNEL_VIRTUAL_BASE 0xC0100000 #define KERNEL_PHYSICAL_BASE 0x00100000 typedef struct kernel_mem_info { uint32_t physical_start; uint32_t physical_end; uint32_t virtual_start; uint32_t virtual_end; } kernel_mem_info_t; void __early map_page(vaddr_t from, size_t count, paddr_t physical); void __early early_init_paging(kernel_mem_info_t kmem_info, uint32_t mb2_addr); #endif // __PAGING_H_ Source file Code: #include "paging.h" #include "../asm.h" uint32_t __earlydata _magic; uint32_t __earlydata _addr; uint64_t __earlydata *last_page_dir; uint64_t __earlydata *last_page_tab; uint64_t __earlydata page_dir_ptr_tab[4]; uint64_t __align(0x1000) __earlydata page_dir[ENTRY_SIZE * 4]; // must be aligned to page boundry uint64_t __align(0x1000) __earlydata page_tab[ENTRY_SIZE * ENTRY_SIZE * 4]; #define ROUNDUP(x, y) (x % y ? x + (y - (x % y)) : x) #define ROUNDDW(x, y) x - (x % y) #define __to_entry(x) ((uint64_t)((uint32_t)x & ENTRY_MASK)) #define __tabn(x) (uint32_t)(((x & PT_MASK) >> 9) & ~3) #define __dirn(x) (uint32_t)(((x & PD_MASK) >> 18) & ~3) #define __ptrn(x) (uint32_t)((x & PDPTR_MASK) >> 30) #define __pfn(x) (uint32_t)(x & 0xFFF) #define __getd(x, y) (uint64_t *)(uint32_t)((x & ENTRY_MASK) | __dirn(y)) #define __gett(x, y) (uint64_t *)(uint32_t)((x & ENTRY_MASK) | __tabn(y)) #define __getp(x, y) (paddr_t)((x & ENTRY_MASK) | __pfn(y)) void __early map_page(vaddr_t from, size_t count, paddr_t physical) { size_t c = count; // Page schema for 32 bits PAE set, PSE unset: // 2 | 9 | 9 | 12 for (; c > 0; from += 0x1000, physical += 0x1000, c -= 0x1000) { uint32_t p = (from & PDPTR_MASK) >> 30; // _ptrn(from & PDPTR_MASK); uint64_t pdpte_i = page_dir_ptr_tab[p]; // check PDPTEi, if P flag is not 1, or pdpte is zero if (!(pdpte_i & 1) || !(pdpte_i & ENTRY_MASK)) { pdpte_i = page_dir_ptr_tab[p] = __to_entry(last_page_dir) | 1; last_page_dir += ENTRY_SIZE; } // retrieve page dir entry base on dir first element and [from] uint64_t *pg_dir_entry = __getd(pdpte_i, from); // Page table should not be zero if (!(*pg_dir_entry & 1) || !(*pg_dir_entry & ENTRY_MASK)) { *pg_dir_entry = __to_entry(last_page_tab) | 3; last_page_tab += ENTRY_SIZE; } uint64_t *pg_tab_entry = __gett(*pg_dir_entry, from); *pg_tab_entry = __to_entry(physical) | 3; } } static paddr_t __early virt_to_phys(vaddr_t vaddr) { uint64_t pdptr_e = page_dir_ptr_tab[__ptrn(vaddr)]; if ((pdptr_e & 1) == 0) { // directory not present return 0; } uint64_t *pg_dir = __getd(pdptr_e, vaddr); if ((*pg_dir & 1) == 0) { return 0; } uint64_t *pg_tab = __gett(*pg_dir, vaddr); if ((*pg_tab & 1) == 0) { return 0; } paddr_t ret = __getp(*pg_tab, vaddr); return ret; } void __early early_init_paging(kernel_mem_info_t kmem_info, uint32_t mb2_addr) { last_page_dir = page_dir; last_page_tab = page_tab; uint32_t ksize = kmem_info.physical_end - kmem_info.physical_start; // identity map first 1 MiB + kernel size. // round up to nearest page boundry uint32_t offset = ROUNDUP(0x100000 + ksize, 4096); map_page((vaddr_t)0, offset, (paddr_t)0); if (virt_to_phys(0x130000) != 0x130000) { while (1) { } // error } // identity map multiboot info loaded address. uint32_t mb2_loaded = ROUNDDW(mb2_addr, 4096); uint32_t size = *((uint32_t *)((void *)mb2_addr)); offset = ROUNDUP(size, 4096); map_page((vaddr_t)mb2_loaded, offset, (paddr_t)mb2_loaded); // map higher half to page, start from 0xC0100000 offset = ROUNDUP((kmem_info.physical_end - kmem_info.physical_start) + 0xB00000, 4096); // + 0x100000; vaddr_t kvb = (vaddr_t)ROUNDUP(KERNEL_VIRTUAL_BASE, 4096); paddr_t pss = (paddr_t)ROUNDUP(kmem_info.physical_start, 4096); map_page(kvb, offset, pss); if (virt_to_phys(KERNEL_VIRTUAL_BASE) != kmem_info.physical_start) { while (1) { } //error } if (virt_to_phys(0xc0403c4c) != 0x00403c4c) { while (1) { } // error } // move PDPTR to CR3 set_cr3((uint32_t)&page_dir_ptr_tab); // set CR4.PAE bit uint32_t cr4 = get_cr4(); cr4 |= 0x20; set_cr4(cr4); // set CR0.PG bit uint32_t cr0 = get_cr0(); cr0 |= 0x80000000; set_cr0(cr0); } objdump -d paging.o > paging.dmp give the following: Code: obj/paging.o: file format elf32-i386 Disassembly of section .text: 00000000 <get_cr0>: ... f: c9 leave 10: c3 ret 00000011 <set_cr0>: ... 1c: c3 ret 0000001d <set_cr3>: ... 27: 5d pop %ebp 28: c3 ret 00000029 <get_cr4>: ... 38: c9 leave 39: c3 ret 0000003a <set_cr4>: ... 44: 5d pop %ebp 45: c3 ret 00000046 <map_page>: 46: 55 push %ebp 47: 89 e5 mov %esp,%ebp ... 2ed: 5d pop %ebp 2ee: c3 ret 000002ef <virt_to_phys>: 2ef: 55 push %ebp 2f0: 89 e5 mov %esp,%ebp ... 429: 5d pop %ebp 42a: c3 ret 0000042b <early_init_paging>: 42b: 55 push %ebp 42c: 89 e5 mov %esp,%ebp ... 5c7: c9 leave 5c8: c3 ret EDIT: Sub Makefile: Code: NASM=nasm GCC=i686-elf-gcc ROOT := ~/projects/qios OBJDIR := $(ROOT)/obj SRCDIR := $(ROOT)/src INC := $(SRCDIR)/include SRC := $(wildcard *.asm) CSRC := $(wildcard *.c) OBJ := $(patsubst %.asm,$(OBJDIR)/%.o,$(SRC)) OBJ += $(patsubst %.c,$(OBJDIR)/%.o,$(CSRC)) ASFLAGS = -felf32 -g CFLAGS=-std=c11 -ffreestanding -Wall -Wextra -Werror -masm=intel -g -O0 --verbose -I $(INC) .PHONY: all clean all : $(OBJ) $(OBJDIR)/%.o : %.asm $(NASM) $(ASFLAGS) -o $@ $< $(OBJDIR)/%.o : %.c $(GCC) -c $< -o $@ $(CFLAGS) debug: echo $(SRC) echo $(Obj) clean: rm -f $(OBJ) When run the command "make clean all" this is the output: Code: make: Entering directory '/home/xxxxxx/projects/qios/src/arch/x86/boot'
rm -f ~/projects/qios/obj/load.o ~/projects/qios/obj/paging.o ~/projects/qios/obj/kernel.o nasm -felf32 -g -o /home/xxxxxx/projects/qios/obj/load.o load.asm load.asm:44: warning: dword data exceeds bounds [-w+number-overflow] i686-elf-gcc -c paging.c -o /home/xxxxxx/projects/qios/obj/paging.o -std=c11 -ffreestanding -Wall -Wextra -Werror -masm=intel -g -O0 --verbose -I ~/projects/qios/src/include Using built-in specs. COLLECT_GCC=i686-elf-gcc Target: i686-elf Configured with: ../gcc-7.2.0/configure --target=i686-elf --prefix=/home/xxxxxx/opt/cross --disable-nls --enable-languages=c,c++ --without-headers Thread model: single gcc version 7.2.0 (GCC) COLLECT_GCC_OPTIONS='-c' '-o' '/home/xxxxxx/projects/qios/obj/paging.o' '-std=c11' '-ffreestanding' '-Wall' '-Wextra' '-Werror' '-masm=intel' '-g' '-O0' '-v' '-I' '/home/xxxxxx/projects/qios/src/include' '-mtune=generic' '-march=pentiumpro' /home/xxxxxx/opt/cross/libexec/gcc/i686-elf/7.2.0/cc1 -quiet -v -I /home/xxxxxx/projects/qios/src/include paging.c -quiet -dumpbase paging.c -masm=intel -mtune=generic -march=pentiumpro -auxbase-strip /home/xxxxxx/projects/qios/obj/paging.o -g -O0 -Wall -Wextra -Werror -std=c11 -version -ffreestanding -o /tmp/ccoajh9T.s GNU C11 (GCC) version 7.2.0 (i686-elf) compiled by GNU C version 7.2.0, GMP version 6.1.2, MPFR version 3.1.6, MPC version 1.0.3, isl version isl-0.18-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 ignoring nonexistent directory "/home/xxxxxx/opt/cross/lib/gcc/i686-elf/7.2.0/../../../../i686-elf/sys-include" ignoring nonexistent directory "/home/xxxxxx/opt/cross/lib/gcc/i686-elf/7.2.0/../../../../i686-elf/include" #include "..." search starts here: #include <...> search starts here: /home/xxxxxx/projects/qios/src/include /home/xxxxxx/opt/cross/lib/gcc/i686-elf/7.2.0/include /home/xxxxxx/opt/cross/lib/gcc/i686-elf/7.2.0/include-fixed End of search list. GNU C11 (GCC) version 7.2.0 (i686-elf) compiled by GNU C version 7.2.0, GMP version 6.1.2, MPFR version 3.1.6, MPC version 1.0.3, isl version isl-0.18-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 01f7fd9f29241f2582c96ff0f48ee445 COLLECT_GCC_OPTIONS='-c' '-o' '/home/xxxxxx/projects/qios/obj/paging.o' '-std=c11' '-ffreestanding' '-Wall' '-Wextra' '-Werror' '-masm=intel' '-g' '-O0' '-v' '-I' '/home/xxxxxx/projects/qios/src/include' '-mtune=generic' '-march=pentiumpro' /home/xxxxxx/opt/cross/lib/gcc/i686-elf/7.2.0/../../../../i686-elf/bin/as -o /home/xxxxxx/projects/qios/obj/paging.o /tmp/ccoajh9T.s COMPILER_PATH=/home/xxxxxx/opt/cross/libexec/gcc/i686-elf/7.2.0/:/home/xxxxxx/opt/cross/libexec/gcc/i686-elf/7.2.0/:/home/xxxxxx/opt/cross/libexec/gcc/i686-elf/:/home/xxxxxx/opt/cross/lib/gcc/i686-elf/7.2.0/:/home/xxxxxx/opt/cross/lib/gcc/i686-elf/:/home/xxxxxx/opt/cross/lib/gcc/i686-elf/7.2.0/../../../../i686-elf/bin/ LIBRARY_PATH=/home/xxxxxx/opt/cross/lib/gcc/i686-elf/7.2.0/:/home/xxxxxx/opt/cross/lib/gcc/i686-elf/7.2.0/../../../../i686-elf/lib/ COLLECT_GCC_OPTIONS='-c' '-o' '/home/xxxxxx/projects/qios/obj/paging.o' '-std=c11' '-ffreestanding' '-Wall' '-Wextra' '-Werror' '-masm=intel' '-g' '-O0' '-v' '-I' '/home/xxxxxx/projects/qios/src/include' '-mtune=generic' '-march=pentiumpro' i686-elf-gcc -c kernel.c -o /home/xxxxxx/projects/qios/obj/kernel.o -std=c11 -ffreestanding -Wall -Wextra -Werror -masm=intel -g -O0 --verbose -I ~/projects/qios/src/include Using built-in specs. COLLECT_GCC=i686-elf-gcc Target: i686-elf Configured with: ../gcc-7.2.0/configure --target=i686-elf --prefix=/home/xxxxxx/opt/cross --disable-nls --enable-languages=c,c++ --without-headers Thread model: single gcc version 7.2.0 (GCC) COLLECT_GCC_OPTIONS='-c' '-o' '/home/xxxxxx/projects/qios/obj/kernel.o' '-std=c11' '-ffreestanding' '-Wall' '-Wextra' '-Werror' '-masm=intel' '-g' '-O0' '-v' '-I' '/home/xxxxxx/projects/qios/src/include' '-mtune=generic' '-march=pentiumpro' /home/xxxxxx/opt/cross/libexec/gcc/i686-elf/7.2.0/cc1 -quiet -v -I /home/xxxxxx/projects/qios/src/include kernel.c -quiet -dumpbase kernel.c -masm=intel -mtune=generic -march=pentiumpro -auxbase-strip /home/xxxxxx/projects/qios/obj/kernel.o -g -O0 -Wall -Wextra -Werror -std=c11 -version -ffreestanding -o /tmp/ccRfYOyW.s GNU C11 (GCC) version 7.2.0 (i686-elf) compiled by GNU C version 7.2.0, GMP version 6.1.2, MPFR version 3.1.6, MPC version 1.0.3, isl version isl-0.18-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 ignoring nonexistent directory "/home/xxxxxx/opt/cross/lib/gcc/i686-elf/7.2.0/../../../../i686-elf/sys-include" ignoring nonexistent directory "/home/xxxxxx/opt/cross/lib/gcc/i686-elf/7.2.0/../../../../i686-elf/include" #include "..." search starts here: #include <...> search starts here: /home/xxxxxx/projects/qios/src/include /home/xxxxxx/opt/cross/lib/gcc/i686-elf/7.2.0/include /home/xxxxxx/opt/cross/lib/gcc/i686-elf/7.2.0/include-fixed End of search list. GNU C11 (GCC) version 7.2.0 (i686-elf) compiled by GNU C version 7.2.0, GMP version 6.1.2, MPFR version 3.1.6, MPC version 1.0.3, isl version isl-0.18-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 01f7fd9f29241f2582c96ff0f48ee445 COLLECT_GCC_OPTIONS='-c' '-o' '/home/xxxxxx/projects/qios/obj/kernel.o' '-std=c11' '-ffreestanding' '-Wall' '-Wextra' '-Werror' '-masm=intel' '-g' '-O0' '-v' '-I' '/home/xxxxxx/projects/qios/src/include' '-mtune=generic' '-march=pentiumpro' /home/xxxxxx/opt/cross/lib/gcc/i686-elf/7.2.0/../../../../i686-elf/bin/as -o /home/xxxxxx/projects/qios/obj/kernel.o /tmp/ccRfYOyW.s COMPILER_PATH=/home/xxxxxx/opt/cross/libexec/gcc/i686-elf/7.2.0/:/home/xxxxxx/opt/cross/libexec/gcc/i686-elf/7.2.0/:/home/xxxxxx/opt/cross/libexec/gcc/i686-elf/:/home/xxxxxx/opt/cross/lib/gcc/i686-elf/7.2.0/:/home/xxxxxx/opt/cross/lib/gcc/i686-elf/:/home/xxxxxx/opt/cross/lib/gcc/i686-elf/7.2.0/../../../../i686-elf/bin/ LIBRARY_PATH=/home/xxxxxx/opt/cross/lib/gcc/i686-elf/7.2.0/:/home/xxxxxx/opt/cross/lib/gcc/i686-elf/7.2.0/../../../../i686-elf/lib/ COLLECT_GCC_OPTIONS='-c' '-o' '/home/xxxxxx/projects/qios/obj/kernel.o' '-std=c11' '-ffreestanding' '-Wall' '-Wextra' '-Werror' '-masm=intel' '-g' '-O0' '-v' '-I' '/home/xxxxxx/projects/qios/src/include' '-mtune=generic' '-march=pentiumpro' make: Leaving directory '/home/xxxxxx/projects/qios/src/arch/x86/boot' |
Author: | xenos [ Sat Dec 16, 2017 12:45 pm ] |
Post subject: | Re: GCC ignoring __attribute__((section(xxx))) |
What is the exact command line you use when compiling your source file? |
Author: | tongko [ Sun Dec 17, 2017 1:46 am ] |
Post subject: | Re: GCC ignoring __attribute__((section(xxx))) |
XenOS wrote: What is the exact command line you use when compiling your source file? I've just added the make file and the output. |
Author: | xenos [ Sun Dec 17, 2017 2:37 am ] |
Post subject: | Re: GCC ignoring __attribute__((section(xxx))) |
To me it looks fine. I would try to run GCC on one of your files "by hand" with -S instead of -c, in order to see the compiled, but not assembled file, that is passed to the assembler. |
Author: | tongko [ Sun Dec 17, 2017 3:44 am ] |
Post subject: | Re: GCC ignoring __attribute__((section(xxx))) |
By changing the -c option to -S, I manually run the following Code: i686-elf-gcc -S paging.c -o /home/xxxxxx/projects/qios/obj/paging.o -std=c11 -ffreestanding -Wall -Wextra -Werror -masm=intel -g -O0 --verbose -I ~/projects/qios/src/include The output is exactly the same as I use option '-c' Code: Using built-in specs. COLLECT_GCC=i686-elf-gcc Target: i686-elf Configured with: ../gcc-7.2.0/configure --target=i686-elf --prefix=/home/xxxxxx/opt/cross --disable-nls --enable-languages=c,c++ --without-headers Thread model: single gcc version 7.2.0 (GCC) COLLECT_GCC_OPTIONS='-S' '-o' '/home/xxxxxx/projects/qios/obj/paging.o' '-std=c11' '-ffreestanding' '-Wall' '-Wextra' '-Werror' '-masm=intel' '-g' '-O0' '-v' '-I' '/home/xxxxxx/projects/qios/src/include' '-mtune=generic' '-march=pentiumpro' /home/xxxxxx/opt/cross/libexec/gcc/i686-elf/7.2.0/cc1 -quiet -v -I /home/xxxxxx/projects/qios/src/include paging.c -quiet -dumpbase paging.c -masm=intel -mtune=generic -march=pentiumpro -auxbase-strip /home/xxxxxx/projects/qios/obj/paging.o -g -O0 -Wall -Wextra -Werror -std=c11 -version -ffreestanding -o /home/xxxxxx/projects/qios/obj/paging.o GNU C11 (GCC) version 7.2.0 (i686-elf) compiled by GNU C version 7.2.0, GMP version 6.1.2, MPFR version 3.1.6, MPC version 1.0.3, isl version isl-0.18-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 ignoring nonexistent directory "/home/xxxxxx/opt/cross/lib/gcc/i686-elf/7.2.0/../../../../i686-elf/sys-include" ignoring nonexistent directory "/home/xxxxxx/opt/cross/lib/gcc/i686-elf/7.2.0/../../../../i686-elf/include" #include "..." search starts here: #include <...> search starts here: /home/xxxxxx/projects/qios/src/include /home/xxxxxx/opt/cross/lib/gcc/i686-elf/7.2.0/include /home/xxxxxx/opt/cross/lib/gcc/i686-elf/7.2.0/include-fixed End of search list. GNU C11 (GCC) version 7.2.0 (i686-elf) compiled by GNU C version 7.2.0, GMP version 6.1.2, MPFR version 3.1.6, MPC version 1.0.3, isl version isl-0.18-GMP GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 01f7fd9f29241f2582c96ff0f48ee445 COMPILER_PATH=/home/xxxxxx/opt/cross/libexec/gcc/i686-elf/7.2.0/:/home/xxxxxx/opt/cross/libexec/gcc/i686-elf/7.2.0/:/home/xxxxxx/opt/cross/libexec/gcc/i686-elf/:/home/xxxxxx/opt/cross/lib/gcc/i686-elf/7.2.0/:/home/xxxxxx/opt/cross/lib/gcc/i686-elf/:/home/xxxxxx/opt/cross/lib/gcc/i686-elf/7.2.0/../../../../i686-elf/bin/ LIBRARY_PATH=/home/xxxxxx/opt/cross/lib/gcc/i686-elf/7.2.0/:/home/xxxxxx/opt/cross/lib/gcc/i686-elf/7.2.0/../../../../i686-elf/lib/ COLLECT_GCC_OPTIONS='-S' '-o' '/home/xxxxxx/projects/qios/obj/paging.o' '-std=c11' '-ffreestanding' '-Wall' '-Wextra' '-Werror' '-masm=intel' '-g' '-O0' '-v' '-I' '/home/xxxxxx/projects/qios/src/include' '-mtune=generic' '-march=pentiumpro' The output .S assembly file doesn't contain the right section, either. Code: .file "paging.c"
.intel_syntax noprefix .text .Ltext0: .type get_cr0, @function get_cr0: .LFB6: .file 1 "../asm.h" .loc 1 57 0 .cfi_startproc push ebp .cfi_def_cfa_offset 8 .cfi_offset 5, -8 mov ebp, esp .cfi_def_cfa_register 5 sub esp, 16 .loc 1 59 0 /APP / 59 "../asm.h" 1 mov eax, cr0 / 0 "" 2 /NO_APP mov DWORD PTR [ebp-4], eax .loc 1 62 0 mov eax, DWORD PTR [ebp-4] .loc 1 63 0 leave .cfi_restore 5 .cfi_def_cfa 4, 4 ret .cfi_endproc .LFE6: .size get_cr0, .-get_cr0 .type set_cr0, @function set_cr0: .LFB7: .loc 1 65 0 .cfi_startproc push ebp .cfi_def_cfa_offset 8 .cfi_offset 5, -8 mov ebp, esp .cfi_def_cfa_register 5 .loc 1 66 0 mov eax, DWORD PTR [ebp+8] /APP / 66 "../asm.h" 1 mov cr0, eax / 0 "" 2 .loc 1 67 0 /NO_APP nop pop ebp .cfi_restore 5 .cfi_def_cfa 4, 4 ret .cfi_endproc .LFE7: .size set_cr0, .-set_cr0 .type set_cr3, @function set_cr3: .LFB9: .loc 1 77 0 .cfi_startproc push ebp .cfi_def_cfa_offset 8 .cfi_offset 5, -8 mov ebp, esp .cfi_def_cfa_register 5 .loc 1 78 0 mov eax, DWORD PTR [ebp+8] /APP / 78 "../asm.h" 1 mov cr3, eax / 0 "" 2 .loc 1 79 0 /NO_APP nop pop ebp .cfi_restore 5 .cfi_def_cfa 4, 4 ret .cfi_endproc .LFE9: .size set_cr3, .-set_cr3 .type get_cr4, @function get_cr4: .LFB10: .loc 1 81 0 .cfi_startproc push ebp .cfi_def_cfa_offset 8 .cfi_offset 5, -8 mov ebp, esp .cfi_def_cfa_register 5 sub esp, 16 .loc 1 83 0 /APP / 83 "../asm.h" 1 mov eax, cr4 / 0 "" 2 /NO_APP mov DWORD PTR [ebp-4], eax .loc 1 86 0 mov eax, DWORD PTR [ebp-4] .loc 1 87 0 leave .cfi_restore 5 .cfi_def_cfa 4, 4 ret .cfi_endproc .LFE10: .size get_cr4, .-get_cr4 .type set_cr4, @function set_cr4: .LFB11: .loc 1 89 0 .cfi_startproc push ebp .cfi_def_cfa_offset 8 .cfi_offset 5, -8 mov ebp, esp .cfi_def_cfa_register 5 .loc 1 90 0 mov eax, DWORD PTR [ebp+8] /APP / 90 "../asm.h" 1 mov cr4, eax / 0 "" 2 .loc 1 91 0 /NO_APP nop pop ebp .cfi_restore 5 .cfi_def_cfa 4, 4 ret .cfi_endproc .LFE11: .size set_cr4, .-set_cr4 .comm _magic,4,4 .comm _addr,4,4 .comm last_page_dir,4,4 .comm last_page_tab,4,4 .comm page_dir_ptr_tab,32,32 .comm page_dir,16384,32 .comm page_tab,8388608,32 .globl map_page .type map_page, @function map_page: .LFB12: .file 2 "paging.c" .loc 2 33 0 .cfi_startproc push ebp .cfi_def_cfa_offset 8 .cfi_offset 5, -8 mov ebp, esp .cfi_def_cfa_register 5 push edi push esi push ebx sub esp, 140 .cfi_offset 7, -12 .cfi_offset 6, -16 .cfi_offset 3, -20 .loc 2 34 0 mov eax, DWORD PTR [ebp+12] mov DWORD PTR [ebp-20], eax .loc 2 37 0 jmp .L9 .L14: .LBB2: .loc 2 38 0 mov eax, DWORD PTR [ebp+8] shr eax, 30 mov DWORD PTR [ebp-36], eax .loc 2 39 0 mov eax, DWORD PTR [ebp-36] mov edx, DWORD PTR page_dir_ptr_tab[4+eax*8] mov eax, DWORD PTR page_dir_ptr_tab[0+eax*8] mov DWORD PTR [ebp-32], eax mov DWORD PTR [ebp-28], edx .loc 2 41 0 mov eax, DWORD PTR [ebp-32] and eax, 1 mov DWORD PTR [ebp-64], eax mov eax, DWORD PTR [ebp-28] and eax, 0 mov DWORD PTR [ebp-60], eax mov eax, DWORD PTR [ebp-64] mov edx, DWORD PTR [ebp-60] mov ebx, eax xor bh, 0 mov DWORD PTR [ebp-56], ebx mov eax, edx xor ah, 0 mov DWORD PTR [ebp-52], eax mov eax, DWORD PTR [ebp-52] or eax, DWORD PTR [ebp-56] test eax, eax je .L10 .loc 2 41 0 is_stmt 0 discriminator 1 mov eax, DWORD PTR [ebp-32] and eax, -4096 mov DWORD PTR [ebp-72], eax mov eax, DWORD PTR [ebp-28] and eax, 1048575 mov DWORD PTR [ebp-68], eax mov eax, DWORD PTR [ebp-72] mov edx, DWORD PTR [ebp-68] mov ebx, eax xor bh, 0 mov esi, ebx mov eax, edx xor ah, 0 mov edi, eax mov eax, edi or eax, esi test eax, eax jne .L11 .L10: .loc 2 42 0 is_stmt 1 mov eax, DWORD PTR last_page_dir mov edx, 0 mov ecx, eax and ecx, -4096 mov DWORD PTR [ebp-80], ecx mov eax, edx and eax, 1048575 mov DWORD PTR [ebp-76], eax mov eax, DWORD PTR [ebp-80] mov edx, DWORD PTR [ebp-76] mov ebx, eax or ebx, 1 mov DWORD PTR [ebp-88], ebx mov eax, edx or ah, 0 mov DWORD PTR [ebp-84], eax mov eax, DWORD PTR [ebp-36] mov ecx, DWORD PTR [ebp-88] mov ebx, DWORD PTR [ebp-84] mov DWORD PTR page_dir_ptr_tab[0+eax*8], ecx mov DWORD PTR page_dir_ptr_tab[4+eax*8], ebx mov eax, DWORD PTR [ebp-36] mov edx, DWORD PTR page_dir_ptr_tab[4+eax*8] mov eax, DWORD PTR page_dir_ptr_tab[0+eax*8] mov DWORD PTR [ebp-32], eax mov DWORD PTR [ebp-28], edx .loc 2 43 0 mov eax, DWORD PTR last_page_dir add eax, 4096 mov DWORD PTR last_page_dir, eax .L11: .loc 2 46 0 mov eax, DWORD PTR [ebp-32] and eax, -4096 mov edx, eax mov eax, DWORD PTR [ebp+8] shr eax, 18 and eax, 4088 or eax, edx mov DWORD PTR [ebp-40], eax .loc 2 48 0 mov eax, DWORD PTR [ebp-40] mov edx, DWORD PTR [eax+4] mov eax, DWORD PTR [eax] mov ecx, eax and ecx, 1 mov DWORD PTR [ebp-96], ecx mov eax, edx and eax, 0 mov DWORD PTR [ebp-92], eax mov eax, DWORD PTR [ebp-96] mov edx, DWORD PTR [ebp-92] mov ebx, eax xor bh, 0 mov DWORD PTR [ebp-144], ebx mov eax, edx xor ah, 0 mov DWORD PTR [ebp-140], eax mov eax, DWORD PTR [ebp-144] mov edx, DWORD PTR [ebp-140] mov ecx, edx or ecx, eax mov eax, ecx test eax, eax je .L12 .loc 2 48 0 is_stmt 0 discriminator 1 mov eax, DWORD PTR [ebp-40] mov edx, DWORD PTR [eax+4] mov eax, DWORD PTR [eax] mov ebx, eax and ebx, -4096 mov DWORD PTR [ebp-104], ebx mov eax, edx and eax, 1048575 mov DWORD PTR [ebp-100], eax mov eax, DWORD PTR [ebp-104] mov edx, DWORD PTR [ebp-100] mov ecx, eax xor ch, 0 mov DWORD PTR [ebp-152], ecx mov eax, edx xor ah, 0 mov DWORD PTR [ebp-148], eax mov eax, DWORD PTR [ebp-152] mov edx, DWORD PTR [ebp-148] mov ebx, edx or ebx, eax mov eax, ebx test eax, eax jne .L13 .L12: .loc 2 49 0 is_stmt 1 mov eax, DWORD PTR last_page_tab mov edx, 0 mov ecx, eax and ecx, -4096 mov DWORD PTR [ebp-112], ecx mov eax, edx and eax, 1048575 mov DWORD PTR [ebp-108], eax mov eax, DWORD PTR [ebp-112] mov edx, DWORD PTR [ebp-108] mov ebx, eax or ebx, 3 mov DWORD PTR [ebp-120], ebx mov eax, edx or ah, 0 mov DWORD PTR [ebp-116], eax mov eax, DWORD PTR [ebp-40] mov ecx, DWORD PTR [ebp-120] mov ebx, DWORD PTR [ebp-116] mov DWORD PTR [eax], ecx mov DWORD PTR [eax+4], ebx .loc 2 50 0 mov eax, DWORD PTR last_page_tab add eax, 4096 mov DWORD PTR last_page_tab, eax .L13: .loc 2 52 0 mov eax, DWORD PTR [ebp-40] mov edx, DWORD PTR [eax+4] mov eax, DWORD PTR [eax] and eax, -4096 mov edx, eax mov eax, DWORD PTR [ebp+8] shr eax, 9 and eax, 4088 or eax, edx mov DWORD PTR [ebp-44], eax .loc 2 53 0 mov eax, DWORD PTR [ebp+16] mov edx, 0 mov ecx, eax and ecx, -4096 mov DWORD PTR [ebp-128], ecx mov eax, edx and eax, 1048575 mov DWORD PTR [ebp-124], eax mov eax, DWORD PTR [ebp-128] mov edx, DWORD PTR [ebp-124] mov ebx, eax or ebx, 3 mov DWORD PTR [ebp-136], ebx mov eax, edx or ah, 0 mov DWORD PTR [ebp-132], eax mov eax, DWORD PTR [ebp-44] mov ecx, DWORD PTR [ebp-136] mov ebx, DWORD PTR [ebp-132] mov DWORD PTR [eax], ecx mov DWORD PTR [eax+4], ebx .LBE2: .loc 2 37 0 add DWORD PTR [ebp+8], 4096 add DWORD PTR [ebp+16], 4096 sub DWORD PTR [ebp-20], 4096 .L9: .loc 2 37 0 is_stmt 0 discriminator 1 cmp DWORD PTR [ebp-20], 0 jne .L14 .loc 2 55 0 is_stmt 1 nop add esp, 140 pop ebx .cfi_restore 3 pop esi .cfi_restore 6 pop edi .cfi_restore 7 pop ebp .cfi_restore 5 .cfi_def_cfa 4, 4 ret .cfi_endproc .LFE12: .size map_page, .-map_page .globl virt_to_phys .type virt_to_phys, @function virt_to_phys: .LFB13: .loc 2 57 0 .cfi_startproc push ebp .cfi_def_cfa_offset 8 .cfi_offset 5, -8 mov ebp, esp .cfi_def_cfa_register 5 push edi push esi push ebx sub esp, 68 .cfi_offset 7, -12 .cfi_offset 6, -16 .cfi_offset 3, -20 .loc 2 58 0 mov eax, DWORD PTR [ebp+8] shr eax, 30 mov edx, DWORD PTR page_dir_ptr_tab[4+eax*8] mov eax, DWORD PTR page_dir_ptr_tab[0+eax*8] mov DWORD PTR [ebp-24], eax mov DWORD PTR [ebp-20], edx .loc 2 59 0 mov eax, DWORD PTR [ebp-24] and eax, 1 mov ecx, eax mov eax, DWORD PTR [ebp-20] and eax, 0 mov ebx, eax mov eax, ecx xor ah, 0 mov esi, eax mov eax, ebx xor ah, 0 mov edi, eax mov eax, edi or eax, esi test eax, eax jne .L16 .loc 2 60 0 mov eax, 0 jmp .L17 .L16: .loc 2 62 0 mov eax, DWORD PTR [ebp-24] and eax, -4096 mov edx, eax mov eax, DWORD PTR [ebp+8] shr eax, 18 and eax, 4088 or eax, edx mov DWORD PTR [ebp-28], eax .loc 2 63 0 mov eax, DWORD PTR [ebp-28] mov edx, DWORD PTR [eax+4] mov eax, DWORD PTR [eax] mov edi, eax and edi, 1 mov DWORD PTR [ebp-56], edi mov eax, edx and eax, 0 mov DWORD PTR [ebp-52], eax mov eax, DWORD PTR [ebp-56] mov edx, DWORD PTR [ebp-52] mov edi, eax xor edi, 0 mov DWORD PTR [ebp-72], edi mov eax, edx xor ah, 0 mov DWORD PTR [ebp-68], eax mov ebx, DWORD PTR [ebp-72] mov esi, DWORD PTR [ebp-68] mov eax, esi or eax, ebx test eax, eax jne .L18 .loc 2 64 0 mov eax, 0 jmp .L17 .L18: .loc 2 66 0 mov eax, DWORD PTR [ebp-28] mov edx, DWORD PTR [eax+4] mov eax, DWORD PTR [eax] and eax, -4096 mov edx, eax mov eax, DWORD PTR [ebp+8] shr eax, 9 and eax, 4088 or eax, edx mov DWORD PTR [ebp-32], eax .loc 2 67 0 mov eax, DWORD PTR [ebp-32] mov edx, DWORD PTR [eax+4] mov eax, DWORD PTR [eax] mov ecx, eax and ecx, 1 mov DWORD PTR [ebp-64], ecx mov eax, edx and eax, 0 mov DWORD PTR [ebp-60], eax mov eax, DWORD PTR [ebp-64] mov edx, DWORD PTR [ebp-60] mov ebx, eax xor bh, 0 mov DWORD PTR [ebp-80], ebx mov eax, edx xor ah, 0 mov DWORD PTR [ebp-76], eax mov ebx, DWORD PTR [ebp-80] mov esi, DWORD PTR [ebp-76] mov eax, esi or eax, ebx test eax, eax jne .L19 .loc 2 68 0 mov eax, 0 jmp .L17 .L19: .loc 2 70 0 mov eax, DWORD PTR [ebp-32] mov edx, DWORD PTR [eax+4] mov eax, DWORD PTR [eax] and eax, -4096 mov edx, eax mov eax, DWORD PTR [ebp+8] and eax, 4095 or eax, edx mov DWORD PTR [ebp-36], eax .loc 2 71 0 mov eax, DWORD PTR [ebp-36] .L17: .loc 2 72 0 add esp, 68 pop ebx .cfi_restore 3 pop esi .cfi_restore 6 pop edi .cfi_restore 7 pop ebp .cfi_restore 5 .cfi_def_cfa 4, 4 ret .cfi_endproc .LFE13: .size virt_to_phys, .-virt_to_phys .globl early_init_paging .type early_init_paging, @function early_init_paging: .LFB14: .loc 2 74 0 .cfi_startproc push ebp .cfi_def_cfa_offset 8 .cfi_offset 5, -8 mov ebp, esp .cfi_def_cfa_register 5 sub esp, 32 .loc 2 75 0 mov DWORD PTR last_page_dir, OFFSET FLAT:page_dir .loc 2 76 0 mov DWORD PTR last_page_tab, OFFSET FLAT:page_tab .loc 2 78 0 mov edx, DWORD PTR [ebp+12] mov eax, DWORD PTR [ebp+8] sub edx, eax mov eax, edx mov DWORD PTR [ebp-4], eax .loc 2 81 0 mov eax, DWORD PTR [ebp-4] and eax, -4096 add eax, 4096 mov DWORD PTR [ebp-8], eax .loc 2 82 0 sub esp, 4 push 0 push DWORD PTR [ebp-8] push 0 call map_page add esp, 16 .loc 2 83 0 sub esp, 4 push 1245184 call virt_to_phys add esp, 8 cmp eax, 1245184 je .L21 .L22: .loc 2 84 0 discriminator 1 jmp .L22 .L21: .loc 2 89 0 mov eax, DWORD PTR [ebp+24] and eax, -4096 mov DWORD PTR [ebp-12], eax .loc 2 90 0 mov eax, DWORD PTR [ebp+24] mov eax, DWORD PTR [eax] mov DWORD PTR [ebp-16], eax .loc 2 91 0 mov eax, DWORD PTR [ebp-16] and eax, 4095 test eax, eax je .L23 .loc 2 91 0 is_stmt 0 discriminator 1 mov eax, DWORD PTR [ebp-16] and eax, -4096 add eax, 4096 jmp .L24 .L23: .loc 2 91 0 discriminator 2 mov eax, DWORD PTR [ebp-16] .L24: .loc 2 91 0 discriminator 4 mov DWORD PTR [ebp-8], eax .loc 2 92 0 is_stmt 1 discriminator 4 sub esp, 4 push DWORD PTR [ebp-12] push DWORD PTR [ebp-8] push DWORD PTR [ebp-12] call map_page add esp, 16 .loc 2 95 0 discriminator 4 mov edx, DWORD PTR [ebp+12] mov eax, DWORD PTR [ebp+8] cmp edx, eax je .L25 .loc 2 95 0 is_stmt 0 discriminator 1 mov edx, DWORD PTR [ebp+12] mov eax, DWORD PTR [ebp+8] mov ecx, edx sub ecx, eax mov edx, DWORD PTR [ebp+8] mov eax, DWORD PTR [ebp+12] sub edx, eax mov eax, edx add eax, ecx add eax, 11538432 jmp .L26 .L25: .loc 2 95 0 discriminator 2 mov edx, DWORD PTR [ebp+12] mov eax, DWORD PTR [ebp+8] sub edx, eax mov eax, edx add eax, 11534336 .L26: .loc 2 95 0 discriminator 4 mov DWORD PTR [ebp-8], eax .loc 2 96 0 is_stmt 1 discriminator 4 mov DWORD PTR [ebp-20], -1072693248 .loc 2 97 0 discriminator 4 mov eax, DWORD PTR [ebp+8] and eax, 4095 test eax, eax je .L27 .loc 2 97 0 is_stmt 0 discriminator 1 mov eax, DWORD PTR [ebp+8] and eax, -4096 add eax, 4096 jmp .L28 .L27: .loc 2 97 0 discriminator 2 mov eax, DWORD PTR [ebp+8] .L28: .loc 2 97 0 discriminator 4 mov DWORD PTR [ebp-24], eax .loc 2 98 0 is_stmt 1 discriminator 4 sub esp, 4 push DWORD PTR [ebp-24] push DWORD PTR [ebp-8] push DWORD PTR [ebp-20] call map_page add esp, 16 .loc 2 99 0 discriminator 4 sub esp, 4 push -1072693248 call virt_to_phys add esp, 8 mov edx, eax mov eax, DWORD PTR [ebp+8] cmp edx, eax je .L29 .L30: .loc 2 100 0 discriminator 2 jmp .L30 .L29: .loc 2 104 0 sub esp, 4 push -1069532084 call virt_to_phys add esp, 8 cmp eax, 4209740 je .L31 .L32: .loc 2 105 0 discriminator 3 jmp .L32 .L31: .loc 2 110 0 mov eax, OFFSET FLAT:page_dir_ptr_tab sub esp, 4 push eax call set_cr3 add esp, 8 .loc 2 113 0 call get_cr4 mov DWORD PTR [ebp-28], eax .loc 2 114 0 or DWORD PTR [ebp-28], 32 .loc 2 115 0 sub esp, 4 push DWORD PTR [ebp-28] call set_cr4 add esp, 8 .loc 2 118 0 call get_cr0 mov DWORD PTR [ebp-32], eax .loc 2 119 0 or DWORD PTR [ebp-32], -2147483648 .loc 2 120 0 sub esp, 4 push DWORD PTR [ebp-32] call set_cr0 add esp, 8 .loc 2 121 0 nop leave .cfi_restore 5 .cfi_def_cfa 4, 4 ret .cfi_endproc .LFE14: .size early_init_paging, .-early_init_paging .Letext0: .file 3 "/home/tongko/projects/qios/src/include/stddef.h" .file 4 "/home/tongko/opt/cross/lib/gcc/i686-elf/7.2.0/include/stdint-gcc.h" .file 5 "../ktypedef.h" .file 6 "paging.h" .section .debug_info,"",@progbits .Ldebug_info0: .long 0x3de .value 0x4 .long .Ldebug_abbrev0 .byte 0x4 .uleb128 0x1 .long .LASF48 .byte 0xc .long .LASF49 .long .LASF50 .long .Ltext0 .long .Letext0-.Ltext0 .long .Ldebug_line0 .uleb128 0x2 .byte 0x4 .byte 0x5 .long .LASF0 .uleb128 0x3 .long .LASF7 .byte 0x3 .byte 0x1c .long 0x37 .uleb128 0x2 .byte 0x4 .byte 0x7 .long .LASF1 .uleb128 0x4 .byte 0x4 .byte 0x5 .string "int" .uleb128 0x2 .byte 0x1 .byte 0x6 .long .LASF2 .uleb128 0x2 .byte 0x2 .byte 0x5 .long .LASF3 .uleb128 0x2 .byte 0x8 .byte 0x5 .long .LASF4 .uleb128 0x2 .byte 0x1 .byte 0x8 .long .LASF5 .uleb128 0x2 .byte 0x2 .byte 0x7 .long .LASF6 .uleb128 0x3 .long .LASF8 .byte 0x4 .byte 0x34 .long 0x37 .uleb128 0x3 .long .LASF9 .byte 0x4 .byte 0x37 .long 0x7e .uleb128 0x2 .byte 0x8 .byte 0x7 .long .LASF10 .uleb128 0x2 .byte 0x4 .byte 0x7 .long .LASF11 .uleb128 0x3 .long .LASF12 .byte 0x5 .byte 0x12 .long 0x68 .uleb128 0x3 .long .LASF13 .byte 0x5 .byte 0x14 .long 0x68 .uleb128 0x5 .long .LASF51 .byte 0x10 .byte 0x6 .byte 0x1d .long 0xdf .uleb128 0x6 .long .LASF14 .byte 0x6 .byte 0x1e .long 0x68 .byte 0 .uleb128 0x6 .long .LASF15 .byte 0x6 .byte 0x1f .long 0x68 .byte 0x4 .uleb128 0x6 .long .LASF16 .byte 0x6 .byte 0x20 .long 0x68 .byte 0x8 .uleb128 0x6 .long .LASF17 .byte 0x6 .byte 0x21 .long 0x68 .byte 0xc .byte 0 .uleb128 0x3 .long .LASF18 .byte 0x6 .byte 0x22 .long 0xa2 .uleb128 0x7 .long .LASF19 .byte 0x2 .byte 0xd .long 0x68 .uleb128 0x5 .byte 0x3 .long _magic .uleb128 0x7 .long .LASF20 .byte 0x2 .byte 0xe .long 0x68 .uleb128 0x5 .byte 0x3 .long _addr .uleb128 0x7 .long .LASF21 .byte 0x2 .byte 0xf .long 0x11d .uleb128 0x5 .byte 0x3 .long last_page_dir .uleb128 0x8 .byte 0x4 .long 0x73 .uleb128 0x7 .long .LASF22 .byte 0x2 .byte 0x10 .long 0x11d .uleb128 0x5 .byte 0x3 .long last_page_tab .uleb128 0x9 .long 0x73 .long 0x144 .uleb128 0xa .long 0x37 .byte 0x3 .byte 0 .uleb128 0x7 .long .LASF23 .byte 0x2 .byte 0x11 .long 0x134 .uleb128 0x5 .byte 0x3 .long page_dir_ptr_tab .uleb128 0x9 .long 0x73 .long 0x166 .uleb128 0xb .long 0x37 .value 0x7ff .byte 0 .uleb128 0x7 .long .LASF24 .byte 0x2 .byte 0x12 .long 0x155 .uleb128 0x5 .byte 0x3 .long page_dir .uleb128 0x9 .long 0x73 .long 0x18a .uleb128 0xc .long 0x37 .long 0xfffff .byte 0 .uleb128 0x7 .long .LASF25 .byte 0x2 .byte 0x13 .long 0x177 .uleb128 0x5 .byte 0x3 .long page_tab .uleb128 0xd .long .LASF36 .byte 0x2 .byte 0x4a .long .LFB14 .long .LFE14-.LFB14 .uleb128 0x1 .byte 0x9c .long 0x23d .uleb128 0xe .long .LASF26 .byte 0x2 .byte 0x4a .long 0xdf .uleb128 0x2 .byte 0x91 .sleb128 0 .uleb128 0xe .long .LASF27 .byte 0x2 .byte 0x4a .long 0x68 .uleb128 0x2 .byte 0x91 .sleb128 16 .uleb128 0xf .long .LASF28 .byte 0x2 .byte 0x4e .long 0x68 .uleb128 0x2 .byte 0x91 .sleb128 -12 .uleb128 0xf .long .LASF29 .byte 0x2 .byte 0x51 .long 0x68 .uleb128 0x2 .byte 0x91 .sleb128 -16 .uleb128 0xf .long .LASF30 .byte 0x2 .byte 0x59 .long 0x68 .uleb128 0x2 .byte 0x91 .sleb128 -20 .uleb128 0xf .long .LASF31 .byte 0x2 .byte 0x5a .long 0x68 .uleb128 0x2 .byte 0x91 .sleb128 -24 .uleb128 0x10 .string "kvb" .byte 0x2 .byte 0x60 .long 0x8c .uleb128 0x2 .byte 0x91 .sleb128 -28 .uleb128 0x10 .string "pss" .byte 0x2 .byte 0x61 .long 0x97 .uleb128 0x2 .byte 0x91 .sleb128 -32 .uleb128 0x10 .string "cr4" .byte 0x2 .byte 0x71 .long 0x68 .uleb128 0x2 .byte 0x91 .sleb128 -36 .uleb128 0x10 .string "cr0" .byte 0x2 .byte 0x76 .long 0x68 .uleb128 0x2 .byte 0x91 .sleb128 -40 .byte 0 .uleb128 0x11 .long .LASF52 .byte 0x2 .byte 0x39 .long 0x97 .long .LFB13 .long .LFE13-.LFB13 .uleb128 0x1 .byte 0x9c .long 0x29d .uleb128 0xe .long .LASF32 .byte 0x2 .byte 0x39 .long 0x8c .uleb128 0x2 .byte 0x91 .sleb128 0 .uleb128 0xf .long .LASF33 .byte 0x2 .byte 0x3a .long 0x73 .uleb128 0x2 .byte 0x91 .sleb128 -32 .uleb128 0xf .long .LASF34 .byte 0x2 .byte 0x3e .long 0x11d .uleb128 0x2 .byte 0x91 .sleb128 -36 .uleb128 0xf .long .LASF35 .byte 0x2 .byte 0x42 .long 0x11d .uleb128 0x2 .byte 0x91 .sleb128 -40 .uleb128 0x10 .string "ret" .byte 0x2 .byte 0x46 .long 0x97 .uleb128 0x2 .byte 0x91 .sleb128 -44 .byte 0 .uleb128 0x12 .long .LASF37 .byte 0x2 .byte 0x21 .long .LFB12 .long .LFE12-.LFB12 .uleb128 0x1 .byte 0x9c .long 0x329 .uleb128 0xe .long .LASF38 .byte 0x2 .byte 0x21 .long 0x8c .uleb128 0x2 .byte 0x91 .sleb128 0 .uleb128 0xe .long .LASF39 .byte 0x2 .byte 0x21 .long 0x2c .uleb128 0x2 .byte 0x91 .sleb128 4 .uleb128 0xe .long .LASF40 .byte 0x2 .byte 0x21 .long 0x97 .uleb128 0x2 .byte 0x91 .sleb128 8 .uleb128 0x10 .string "c" .byte 0x2 .byte 0x22 .long 0x2c .uleb128 0x2 .byte 0x91 .sleb128 -28 .uleb128 0x13 .long .LBB2 .long .LBE2-.LBB2 .uleb128 0x10 .string "p" .byte 0x2 .byte 0x26 .long 0x68 .uleb128 0x2 .byte 0x91 .sleb128 -44 .uleb128 0xf .long .LASF41 .byte 0x2 .byte 0x27 .long 0x73 .uleb128 0x2 .byte 0x91 .sleb128 -40 .uleb128 0xf .long .LASF42 .byte 0x2 .byte 0x2e .long 0x11d .uleb128 0x2 .byte 0x91 .sleb128 -48 .uleb128 0xf .long .LASF43 .byte 0x2 .byte 0x34 .long 0x11d .uleb128 0x2 .byte 0x91 .sleb128 -52 .byte 0 .byte 0 .uleb128 0x14 .long .LASF44 .byte 0x1 .byte 0x59 .long .LFB11 .long .LFE11-.LFB11 .uleb128 0x1 .byte 0x9c .long 0x34d .uleb128 0x15 .string "val" .byte 0x1 .byte 0x59 .long 0x68 .uleb128 0x2 .byte 0x91 .sleb128 0 .byte 0 .uleb128 0x16 .long .LASF53 .byte 0x1 .byte 0x51 .long 0x68 .long .LFB10 .long .LFE10-.LFB10 .uleb128 0x1 .byte 0x9c .long 0x375 .uleb128 0x10 .string "ret" .byte 0x1 .byte 0x52 .long 0x68 .uleb128 0x2 .byte 0x91 .sleb128 -12 .byte 0 .uleb128 0x14 .long .LASF45 .byte 0x1 .byte 0x4d .long .LFB9 .long .LFE9-.LFB9 .uleb128 0x1 .byte 0x9c .long 0x399 .uleb128 0x15 .string "val" .byte 0x1 .byte 0x4d .long 0x68 .uleb128 0x2 .byte 0x91 .sleb128 0 .byte 0 .uleb128 0x14 .long .LASF46 .byte 0x1 .byte 0x41 .long .LFB7 .long .LFE7-.LFB7 .uleb128 0x1 .byte 0x9c .long 0x3bd .uleb128 0x15 .string "val" .byte 0x1 .byte 0x41 .long 0x68 .uleb128 0x2 .byte 0x91 .sleb128 0 .byte 0 .uleb128 0x17 .long .LASF47 .byte 0x1 .byte 0x39 .long 0x68 .long .LFB6 .long .LFE6-.LFB6 .uleb128 0x1 .byte 0x9c .uleb128 0x10 .string "ret" .byte 0x1 .byte 0x3a .long 0x68 .uleb128 0x2 .byte 0x91 .sleb128 -12 .byte 0 .byte 0 .section .debug_abbrev,"",@progbits .Ldebug_abbrev0: .uleb128 0x1 .uleb128 0x11 .byte 0x1 .uleb128 0x25 .uleb128 0xe .uleb128 0x13 .uleb128 0xb .uleb128 0x3 .uleb128 0xe .uleb128 0x1b .uleb128 0xe .uleb128 0x11 .uleb128 0x1 .uleb128 0x12 .uleb128 0x6 .uleb128 0x10 .uleb128 0x17 .byte 0 .byte 0 .uleb128 0x2 .uleb128 0x24 .byte 0 .uleb128 0xb .uleb128 0xb .uleb128 0x3e .uleb128 0xb .uleb128 0x3 .uleb128 0xe .byte 0 .byte 0 .uleb128 0x3 .uleb128 0x16 .byte 0 .uleb128 0x3 .uleb128 0xe .uleb128 0x3a .uleb128 0xb .uleb128 0x3b .uleb128 0xb .uleb128 0x49 .uleb128 0x13 .byte 0 .byte 0 .uleb128 0x4 .uleb128 0x24 .byte 0 .uleb128 0xb .uleb128 0xb .uleb128 0x3e .uleb128 0xb .uleb128 0x3 .uleb128 0x8 .byte 0 .byte 0 .uleb128 0x5 .uleb128 0x13 .byte 0x1 .uleb128 0x3 .uleb128 0xe .uleb128 0xb .uleb128 0xb .uleb128 0x3a .uleb128 0xb .uleb128 0x3b .uleb128 0xb .uleb128 0x1 .uleb128 0x13 .byte 0 .byte 0 .uleb128 0x6 .uleb128 0xd .byte 0 .uleb128 0x3 .uleb128 0xe .uleb128 0x3a .uleb128 0xb .uleb128 0x3b .uleb128 0xb .uleb128 0x49 .uleb128 0x13 .uleb128 0x38 .uleb128 0xb .byte 0 .byte 0 .uleb128 0x7 .uleb128 0x34 .byte 0 .uleb128 0x3 .uleb128 0xe .uleb128 0x3a .uleb128 0xb .uleb128 0x3b .uleb128 0xb .uleb128 0x49 .uleb128 0x13 .uleb128 0x3f .uleb128 0x19 .uleb128 0x2 .uleb128 0x18 .byte 0 .byte 0 .uleb128 0x8 .uleb128 0xf .byte 0 .uleb128 0xb .uleb128 0xb .uleb128 0x49 .uleb128 0x13 .byte 0 .byte 0 .uleb128 0x9 .uleb128 0x1 .byte 0x1 .uleb128 0x49 .uleb128 0x13 .uleb128 0x1 .uleb128 0x13 .byte 0 .byte 0 .uleb128 0xa .uleb128 0x21 .byte 0 .uleb128 0x49 .uleb128 0x13 .uleb128 0x2f .uleb128 0xb .byte 0 .byte 0 .uleb128 0xb .uleb128 0x21 .byte 0 .uleb128 0x49 .uleb128 0x13 .uleb128 0x2f .uleb128 0x5 .byte 0 .byte 0 .uleb128 0xc .uleb128 0x21 .byte 0 .uleb128 0x49 .uleb128 0x13 .uleb128 0x2f .uleb128 0x6 .byte 0 .byte 0 .uleb128 0xd .uleb128 0x2e .byte 0x1 .uleb128 0x3f .uleb128 0x19 .uleb128 0x3 .uleb128 0xe .uleb128 0x3a .uleb128 0xb .uleb128 0x3b .uleb128 0xb .uleb128 0x27 .uleb128 0x19 .uleb128 0x11 .uleb128 0x1 .uleb128 0x12 .uleb128 0x6 .uleb128 0x40 .uleb128 0x18 .uleb128 0x2116 .uleb128 0x19 .uleb128 0x1 .uleb128 0x13 .byte 0 .byte 0 .uleb128 0xe .uleb128 0x5 .byte 0 .uleb128 0x3 .uleb128 0xe .uleb128 0x3a .uleb128 0xb .uleb128 0x3b .uleb128 0xb .uleb128 0x49 .uleb128 0x13 .uleb128 0x2 .uleb128 0x18 .byte 0 .byte 0 .uleb128 0xf .uleb128 0x34 .byte 0 .uleb128 0x3 .uleb128 0xe .uleb128 0x3a .uleb128 0xb .uleb128 0x3b .uleb128 0xb .uleb128 0x49 .uleb128 0x13 .uleb128 0x2 .uleb128 0x18 .byte 0 .byte 0 .uleb128 0x10 .uleb128 0x34 .byte 0 .uleb128 0x3 .uleb128 0x8 .uleb128 0x3a .uleb128 0xb .uleb128 0x3b .uleb128 0xb .uleb128 0x49 .uleb128 0x13 .uleb128 0x2 .uleb128 0x18 .byte 0 .byte 0 .uleb128 0x11 .uleb128 0x2e .byte 0x1 .uleb128 0x3f .uleb128 0x19 .uleb128 0x3 .uleb128 0xe .uleb128 0x3a .uleb128 0xb .uleb128 0x3b .uleb128 0xb .uleb128 0x27 .uleb128 0x19 .uleb128 0x49 .uleb128 0x13 .uleb128 0x11 .uleb128 0x1 .uleb128 0x12 .uleb128 0x6 .uleb128 0x40 .uleb128 0x18 .uleb128 0x2117 .uleb128 0x19 .uleb128 0x1 .uleb128 0x13 .byte 0 .byte 0 .uleb128 0x12 .uleb128 0x2e .byte 0x1 .uleb128 0x3f .uleb128 0x19 .uleb128 0x3 .uleb128 0xe .uleb128 0x3a .uleb128 0xb .uleb128 0x3b .uleb128 0xb .uleb128 0x27 .uleb128 0x19 .uleb128 0x11 .uleb128 0x1 .uleb128 0x12 .uleb128 0x6 .uleb128 0x40 .uleb128 0x18 .uleb128 0x2117 .uleb128 0x19 .uleb128 0x1 .uleb128 0x13 .byte 0 .byte 0 .uleb128 0x13 .uleb128 0xb .byte 0x1 .uleb128 0x11 .uleb128 0x1 .uleb128 0x12 .uleb128 0x6 .byte 0 .byte 0 .uleb128 0x14 .uleb128 0x2e .byte 0x1 .uleb128 0x3 .uleb128 0xe .uleb128 0x3a .uleb128 0xb .uleb128 0x3b .uleb128 0xb .uleb128 0x27 .uleb128 0x19 .uleb128 0x11 .uleb128 0x1 .uleb128 0x12 .uleb128 0x6 .uleb128 0x40 .uleb128 0x18 .uleb128 0x2117 .uleb128 0x19 .uleb128 0x1 .uleb128 0x13 .byte 0 .byte 0 .uleb128 0x15 .uleb128 0x5 .byte 0 .uleb128 0x3 .uleb128 0x8 .uleb128 0x3a .uleb128 0xb .uleb128 0x3b .uleb128 0xb .uleb128 0x49 .uleb128 0x13 .uleb128 0x2 .uleb128 0x18 .byte 0 .byte 0 .uleb128 0x16 .uleb128 0x2e .byte 0x1 .uleb128 0x3 .uleb128 0xe .uleb128 0x3a .uleb128 0xb .uleb128 0x3b .uleb128 0xb .uleb128 0x27 .uleb128 0x19 .uleb128 0x49 .uleb128 0x13 .uleb128 0x11 .uleb128 0x1 .uleb128 0x12 .uleb128 0x6 .uleb128 0x40 .uleb128 0x18 .uleb128 0x2117 .uleb128 0x19 .uleb128 0x1 .uleb128 0x13 .byte 0 .byte 0 .uleb128 0x17 .uleb128 0x2e .byte 0x1 .uleb128 0x3 .uleb128 0xe .uleb128 0x3a .uleb128 0xb .uleb128 0x3b .uleb128 0xb .uleb128 0x27 .uleb128 0x19 .uleb128 0x49 .uleb128 0x13 .uleb128 0x11 .uleb128 0x1 .uleb128 0x12 .uleb128 0x6 .uleb128 0x40 .uleb128 0x18 .uleb128 0x2117 .uleb128 0x19 .byte 0 .byte 0 .byte 0 .section .debug_aranges,"",@progbits .long 0x1c .value 0x2 .long .Ldebug_info0 .byte 0x4 .byte 0 .value 0 .value 0 .long .Ltext0 .long .Letext0-.Ltext0 .long 0 .long 0 .section .debug_line,"",@progbits .Ldebug_line0: .section .debug_str,"MS",@progbits,1 .LASF35: .string "pg_tab" .LASF50: .string "/home/tongko/projects/qios/src/arch/x86/boot" .LASF38: .string "from" .LASF33: .string "pdptr_e" .LASF36: .string "early_init_paging" .LASF39: .string "count" .LASF14: .string "physical_start" .LASF18: .string "kernel_mem_info_t" .LASF28: .string "ksize" .LASF9: .string "uint64_t" .LASF19: .string "_magic" .LASF49: .string "paging.c" .LASF26: .string "kmem_info" .LASF24: .string "page_dir" .LASF45: .string "set_cr3" .LASF44: .string "set_cr4" .LASF5: .string "unsigned char" .LASF1: .string "long unsigned int" .LASF6: .string "short unsigned int" .LASF7: .string "size_t" .LASF42: .string "pg_dir_entry" .LASF15: .string "physical_end" .LASF32: .string "vaddr" .LASF25: .string "page_tab" .LASF40: .string "physical" .LASF47: .string "get_cr0" .LASF46: .string "set_cr0" .LASF53: .string "get_cr4" .LASF37: .string "map_page" .LASF11: .string "unsigned int" .LASF27: .string "mb2_addr" .LASF10: .string "long long unsigned int" .LASF41: .string "pdpte_i" .LASF52: .string "virt_to_phys" .LASF16: .string "virtual_start" .LASF21: .string "last_page_dir" .LASF4: .string "long long int" .LASF29: .string "offset" .LASF34: .string "pg_dir" .LASF3: .string "short int" .LASF51: .string "kernel_mem_info" .LASF43: .string "pg_tab_entry" .LASF8: .string "uint32_t" .LASF0: .string "long int" .LASF2: .string "signed char" .LASF17: .string "virtual_end" .LASF13: .string "paddr_t" .LASF23: .string "page_dir_ptr_tab" .LASF31: .string "size" .LASF30: .string "mb2_loaded" .LASF48: .string "GNU C11 7.2.0 -masm=intel -mtune=generic -march=pentiumpro -g -O0 -std=c11 -ffreestanding" .LASF20: .string "_addr" .LASF12: .string "vaddr_t" .LASF22: .string "last_page_tab" .ident "GCC: (GNU) 7.2.0" |
Author: | xenos [ Sun Dec 17, 2017 6:31 am ] |
Post subject: | Re: GCC ignoring __attribute__((section(xxx))) |
By the way, shouldn't the section attribute come after the argument list of the function, instead of before the function name? So instead of Code: void __early myfunc(int arg) { rather Code: void myfunc(int arg) __early {
|
Author: | tongko [ Sun Dec 17, 2017 10:34 am ] |
Post subject: | Re: GCC ignoring __attribute__((section(xxx))) |
so I tried before, after signature, before and after function body, and nothing changed. BTW, not even the section I put on my variable being generated. Code: uint32_t __earlydata _magic; uint32_t __earlydata _addr; uint64_t __earlydata *last_page_dir; uint64_t __earlydata *last_page_tab; uint64_t __earlydata page_dir_ptr_tab[4]; these few are being mark as section ".earlydata", and as you can see in the code, I'm not initializing these variables, GCC shouldn't have move these to anywhere else except the section I assign to it. |
Author: | tongko [ Tue Dec 19, 2017 9:42 am ] |
Post subject: | Re: GCC ignoring __attribute__((section(xxx))) |
I want to apologies all that spent time looking into this issue, I should have attached entire macro header. The problem of this are cause by the file where I define the shortcut macro, attribs.h. I take your advise, try to think that one of the file are corrupting the macro, so I put in minimum compilable code then add 1 after another, then I found that once the macro for cdecl is in, the whole thing happen again. Code: #ifndef __ATTRIBS_H_ #define __ATTRIBS_H_ #ifndef __sect #define __sect(S) __attribute__((section(#S))) #endif #define __early __sect(.early) #define __earlydata __sect(.earlydata) #ifndef __align #define __align(x) __attribute__((aligned(x))) #endif #ifndef __packed #define __packed __attribute__((packed)) #endif #ifndef __cdecl #define __attribute__(cdecl) #endif #endif // __ATTRIBS_H_ But I have no idea why adding the cdecl would yield previous macro malfunction. Thought I read that GCC default to cdecl calling convention, but I just add it for other compiler that wasn't, I think I screw up badly, maybe I should have add checking like #ifndef __GNU__ to detect if the compiler is not gcc. Still a lot to learn! EDIT: After posting it, I think I see where's the problem. The last define are malformed. I think it should be Code: #ifndef __cdecl #define [b]__cdecl[/b] __attribute__(cdecl) #endif will give it a shot. |
Author: | davidv1992 [ Tue Dec 19, 2017 11:25 am ] |
Post subject: | Re: GCC ignoring __attribute__((section(xxx))) |
The problem you could very well be responsible for part of your troubles, as it effectively makes __attribute__() a 1-argument empty macro. Depending on in what order the preprocessor applies expansions (I forgot what the exact rules were for this), this effectively removes the section attribute. |
Author: | tongko [ Tue Dec 19, 2017 9:09 pm ] |
Post subject: | Re: GCC ignoring __attribute__((section(xxx))) |
davidv1992 wrote: The problem you could very well be responsible for part of your troubles, as it effectively makes __attribute__() a 1-argument empty macro. Depending on in what order the preprocessor applies expansions (I forgot what the exact rules were for this), this effectively removes the section attribute. Thanks for the explanation, now I have a much clearer view about this. |
Page 1 of 1 | All times are UTC - 6 hours |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |