Problem with objcopy

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Neuromancer

Problem with objcopy

Post 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
User avatar
Solar
Member
Member
Posts: 7615
Joined: Thu Nov 16, 2006 12:01 pm
Location: Germany
Contact:

Re:Problem with objcopy

Post 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?
Every good solution is obvious once you've found it.
Neuromancer

Re:Problem with objcopy

Post 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.
Post Reply