I have bad issue with objcopy.
I rewrote my OS, and it is now made of 2 assembly source files. The first contains code which goes in .text section, the other one code which goes in the .bss section.
I assemble them with nasm (nasm -f elf) and link with ld with a custom script file.
The script puts every .text sections in the final .text, the .data, .bss, .rodata and COMMON in .data and .init in .init.
Everything is ok, but since ld adds other sections such as .shstrtab, etc. I use objcopy to leave only .text, .data and .init and it exits saying "File truncated".
In another small OS I wrote, using the same script file, it works fine.
The script is:
OUTPUT_ARCH(i386)
OUTPUT_FORMAT(elf32-i386)
ENTRY(_entry)
SECTIONS
{
. = 0x100000;
_start = .;
.text :
{
_text_start = .;
*(.text);
_text_end = .;
}
.data :
{
_data_start = .;
*(.rodata);
*(.data);
*(.bss);
*(COMMON);
_data_end = .;
}
.init :
{
. = ALIGN(4096);
_init_start = .;
*(.init);
. = ALIGN(4096);
_init_end = .;
}
_end = .;
}
Thanks in advance
Problem with objcopy
Re:Problem with objcopy
Erm... a bit besides your question, but isn't bss a section that is zero-initialized on startup? How could that possibly hold code?
Every good solution is obvious once you've found it.
Re:Problem with objcopy
Sorry, actually the .bss section only contains "resb" and "resd", so there is no code in it.
Don't know how to figure it out.
Don't know how to figure it out.