On Mon, Jan 27, 2025 at 08:53:23PM +0800, Liam Zhang wrote:
> Hi,
> 
> I'm using manjaro linux and the objcopy version is 2.43.0.
> 
> I met a severe problem when building XV6 for x86.  It produced a huge img.
> Later I tracked down to the objcopy command.  That's the reason.
> 
> *objcopy -S -O binary initcode.out initcode*
> 
> The initcode.out is 752 bytes, but the output initcode file is 134512860
> bytes, which is insane.

No, there is nothing wrong here at all.  You asked for a binary output
from an input file that has two wildly separated loadable segments.
So you get a binary output with a lot of zeros covering the difference
in addresses.

objdump -hw /tmp/initcode.out

/tmp/initcode.out:     file format elf32-i386

Sections:
Idx Name               Size      VMA       LMA       File off  Algn  Flags
  0 .note.gnu.property 00000028  080480b4  080480b4  000000e0  2**2  CONTENTS, 
ALLOC, LOAD, READONLY, DATA
  1 .text              0000002c  00000000  00000000  000000b4  2**2  CONTENTS, 
ALLOC, LOAD, CODE


> This command works well for objcopy-2.34.

You are mistaken.  objcopy-2.34 gives the same output.

> the initcode.out is attached, please verify it.
> Thank you.
> 
> Liam Zhang



-- 
Alan Modra

Reply via email to