Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linker script for Kernel can be modified to be more compatible. #3

Open
FishyFizz opened this issue Apr 8, 2022 · 0 comments
Open

Comments

@FishyFizz
Copy link

gcc --version
gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0

My build of ucore kernel won't start properly and enters a reboot cycle. I compared my build with a working build and found that the GDT Descriptor that's used in pmm_init() is replaced with zero value when memset(edata, 0, end - edata) is performed.

Disassembly shows that the pmm.o has the GDT Descriptor in section .data.rel.local rather than .data.
After linking, this address is put after .data section in Kernel. This means that the edata symbol defining the end of the .data section will appear before the GDT Descriptor.

//linker script producing the issue
.data : {
    *(.data)
}
PROVIDE(edata = .);

Modify the linker script and make all data type section before edata symble will fix the issue and the kernel will run fine.

//modified linker script
.data : {
    *(.data.*)
}
PROVIDE(edata = .);
@FishyFizz FishyFizz changed the title Linker script for Kernel can be modified to be compatible with newer GCC Linker script for Kernel can be modified to be more compatible. Apr 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant