ELF_i386 !!!
How do I align segments in the output elf file?
gcc aligns segments to 64 bytes
ld aligns to 4096 bytes.
I found this out by looking at the output program header (p_align)
https://en.wikipedia.org/wiki/Executable_and_Linkable_Formathttps://refspecs.linuxbase.org/elf/elf.pdfI know that a good alignment improves the speed of the program. I don't know elf files that well. But how can I align segments on my own?
ld --help. I found parameters that remove the alignment:
-n, --nmagic Do not page align data
-N, --omagic Do not page align data, do not make text readonly
It also contains, but different elf formats (not elf_i386).
--file-alignment <size> Set file alignment
--section-alignment <size> Set section alignment
My usual linking
#/bin/bash
ld -m elf_i386 -o main main.o
remove alignment
#/bin/bash
ld -m elf_i386 -n -o main main.o