my platform:
Host: | OS: Ubuntu 20 LTS | Kernel: Microsoft WSL2 Linux Kernel | Cross compile Toolchain: arm-linux-gnueabi-gcc |__Target: | Board: Waveshare CoreH7XXI | SOC: stm32h743 (Single Core Cortex M7 @400MHz) | Architecture: ARMV7e-M | Onboard DRAM: 8MB - 2.9MB(u-boot and kernel) = 5.1MB Free Space | Linux Kernel: 5.8.10 (stable 2020-09-17) | Busybox: latest stable version |__
Firstoff, my platform is MMU-less, and MMU-less platforms cannot run normal ET_EXEC type elf and the format of the executables should be FDPIC_ELF (an ELF with ET_DYN
type and should be PICPIE/(Position Independent Code/Executable)).
this is my sample program:
#include <stdio.h>int main() { printf("Hello World!"); return 0;}
I want to compile it in a way that it won't rely on external shared libraries (e.g. ld-linux.so.3 and libc.so.6), because the kernel loads the whole libraries into ram and they consume a lot of RAM!
How can I compile my program to be an elf with ET_DYN
type and PIC/PIE
but without using external shared libs. Note that if I use -static
, the generated elf cannot be an ET_DYN
and PIC/PIE
type. So, what should I do???