This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

No loadable segment for a section with custom base address


Hi

My situation might be a bit unusual. I am trying to implement an SMP
x86_64 OS. By default my .text area is loaded at 1M. And it works
fine. Now I want to initialize SMP processors that start in real-time
mode and can access memory only under 64K. I need to load a small init
code to that lowmemory area (the init code switches to protected mode,
does some basic initialization and then jumps to a C function in the
main .text area). So my question is how to load a small part of text
to low memory?

Right now I have start_smp_trampoline.S. I want to compile this file
with base address 40K. The only way to specify the base address I
found is to create a separate ELF segment

    .smp.trampoline 40K : {
        __smp_trampoline_start = .;
        KEEP(*(.smp.trampoline))
        __smp_trampoline_end = .;
    }

It compiles and links fine. objdump shows addresses used in this
trampoline segment are good. If linker created a segment loadable to
40K address and put my .smp.trampoline there it would probably solved
my problem. But the linker does not add an additional loadable segment
for it, hmm, why?

If not adding a separate segment for .smp.trampoline section is
intentional then I need to find another way to load my .smp.trampoline
text to 40K address. I can do it in my OS code but I need to embed
.smp.trampoline text to the main .text (or .rodata) section (the one
loaded to 1M region), then find offset/size of the trampoline code.
How to do that? Is there a way to embed a portion of text with a
custom base address into another section that has different base
address?

Thanks for your help in advance.

I use binutils 2.29.1 and gcc 7.2.0


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]