Merge several libs into a single one
Posted: Tue Nov 26, 2019 12:00 pm
My project is to generate a binary file for reading by a motorola 680x0. The idea is to make a ROM inspired by the model of Amiga, ie the kernel is composed of multiple libraries. For this, first a few context elements:
- GNU m68k-elf-*
- CMake 3.x
- the projet structure :
src/bootstrap/bootstrap.s contains the assembler code to handle the startup of the 680x0 and the directories devices/ and libraries/ contain the sources of the different "modules". For more details: https://gitlab.mimicprod.net/os/miga.
I use CMake to make static libraries, which gives me a libXXXXXX.a for each module and bootstrap, all in ELF format. Now, I want to put all these .a in one file (ELF or binary). For that, I have this file for the linker:
The problem is that the produced file contains only the code source of bootstrap.s and no trace of the other dependencies.
A small idea of how to merge all the code into a single file (ELF or binary) while managing the relocations ?
Is generating static libraries the correct process, would shared libraries be more appropriate ?
- GNU m68k-elf-*
- CMake 3.x
- the projet structure :
Code: Select all
src/
├── bootstrap
│ └── bootstrap.s
├── devices
│ ├── input.device
│ └── serial.device
└── libraries
├─ dos.library
├─ exec.library
└─ graphics.library
I use CMake to make static libraries, which gives me a libXXXXXX.a for each module and bootstrap, all in ELF format. Now, I want to put all these .a in one file (ELF or binary). For that, I have this file for the linker:
Code: Select all
MEMORY {
ram (rwx): ORIGIN = 0x0, LENGTH = 15M
rom (rx): ORIGIN = 0xF00000, LENGTH = 1M
};
PROVIDE (_stack = ORIGIN(ram) + LENGTH(ram));
ENTRY (_reset_handler);
SECTIONS
{
.text : {
*(.text*)
*(.data*)
*(.bss*)
. = ALIGN(4);
} >rom
};
A small idea of how to merge all the code into a single file (ELF or binary) while managing the relocations ?
Is generating static libraries the correct process, would shared libraries be more appropriate ?