Problem with linking script

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Enerccio
Posts: 10
Joined: Sat Sep 01, 2012 7:17 am

Problem with linking script

Post by Enerccio »

For some reason, even though I specify directly in my linking script where some sections should be, linker moves them around and ends up with inccorect layout that can't be linked together.

Summary of my problem: http://stackoverflow.com/questions/3445 ... should-not

I need those sections for smp ap processors, and if I declare them nobits, they end up in -2GB kernel space, completely unusable and kernel won't even link anymore:

Code: Select all

entry.s:(.mp_entry+0x1): relocation truncated to fit: R_X86_64_32 against `.ap_data,'
	utils/collections/array.o \
entry.s:(.mp_entry+0x11): relocation truncated to fit: R_X86_64_32 against `.ap_data,'
	-ffreestanding -mno-red-zone -nostdlib -lgcc -lc -z max-page-size=0x1000   -O0  -L../kclib/usr/lib
entry.s:(.mp_entry+0x25): relocation truncated to fit: R_X86_64_32 against `.ap_stack,'
entry_o.o: In function `cpu_boot_continue':
entry.s:(.mp_entry+0x39): relocation truncated to fit: R_X86_64_32 against `.ap_data,'
onlyonemac
Member
Member
Posts: 1146
Joined: Sat Mar 01, 2014 2:59 pm

Re: Problem with linking script

Post by onlyonemac »

It's generally better to summarise your problem in the thread than to link to a summary elsewhere.
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing
User avatar
xenos
Member
Member
Posts: 1121
Joined: Thu Aug 11, 2005 11:00 pm
Libera.chat IRC: xenos1984
Location: Tartu, Estonia
Contact:

Re: Problem with linking script

Post by xenos »

You might need to manually create different output segments with the PHDRS command:
https://sourceware.org/binutils/docs/ld/PHDRS.html
See the .user section here, for example:
https://github.com/xenos1984/NOS/blob/m ... 4/ldscript
Also, instead of BLOCK, you could try to write out the address of your ap_stack section, since you want it to be fixed anyway.
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS
Post Reply