Page 1 of 1

Problem with objcopy

Posted: Fri Apr 30, 2004 1:36 pm
by Neuromancer
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

Re:Problem with objcopy

Posted: Fri Apr 30, 2004 3:51 pm
by Solar
Erm... a bit besides your question, but isn't bss a section that is zero-initialized on startup? How could that possibly hold code?

Re:Problem with objcopy

Posted: Sat May 01, 2004 10:00 am
by Neuromancer
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.