How to add two "targets" using linker scripts

Viewed 52

As I have stated previously, both my ASM and C skills are not up to scratch so please be patient with me.

I am in the process of writing a bootloader in C and have begun to rub up against the 512 byte limit, but I am not sure how to configure my linker script to split my file into two 512b segments so that I can load on from the other. My current linker script is as follows:

linker.ld

ENTRY(main);
SECTIONS
{    
    . = 0x7C00;    
    .text : AT(0x7C00)
    {
        _text = .;
        *(.text);
        _text_end = .;
    }
    .data :
    {
        _data = .;
        *(.bss);
        *(.bss*);
        *(.data);
        *(.rodata*);
        *(COMMON)
        _data_end = .;
    }    
    .sig : AT(0x7DFE)    
    {        
        SHORT(0xaa55);
    }    
    /DISCARD/ :
    {
        *(.note*);
        *(.iplt*);
        *(.igot*);
        *(.rel*);
        *(.comment);
    }
}

However, despite trying to research them online I cannot for the life of me understand this enough to go about what I am trying to do.

I can achieve what I am trying to do in assembly but I would rather keep this project solely in C

Help is massively appreciated!

And to clarify (as my initial statement seems rather nonsensical in retrospect), I need a way to load one compiled file padded to 512b into a binary with the magic word present, and then do the same to another file without the magic word with the end result being a single binary

0 Answers
Related