Problem with objcopy
Posted: Fri Apr 30, 2004 1:36 pm
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
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