Menu

#512 objcopy: elf_update() failed: Layout constraint violation

RELEASE_1_0
accepted
Kai Wang
freebsd (2)
elfcopy
2016-02-29
2016-01-19
No

When using elfcopy as objcopy targeting mips64 we get a failure building a bootloader. The failing command is:

$ objcopy -S -O binary flashboot.elf flashboot
objcopy: elf_update() failed: Layout constraint violation

The failing file is attached.

A secondary problem is that an empty desitiation file is created even during failure which may cause subsequent builds to falsely succeed.

The probably can be reproduced in FreeBSD-HEAD with:

make TARGET=mips TARGET_ARCH=mips64 -DWITH_ELFCOPY_AS_OBJCOPY buildworld

1 Attachments

Discussion

  • Joseph Koshy

    Joseph Koshy - 2016-01-19
    • Milestone: 2.0 --> RELEASE_1_0
     
  • Kai Wang

    Kai Wang - 2016-01-20
    • status: new --> accepted
    • assigned_to: Kai Wang
     
  • Ed Maste

    Ed Maste - 2016-01-20

    The offending section is this one, which claims 16-byte alignment but is at an offset of 0x78:

    Section Headers: 
      [Nr] Name              Type             Address           Offset
                Size              EntSize          Flags  Link  Info  Align
    ...
      [ 1] .text             PROGBITS         9800000000100078  00000078
                0000000000004df8  0000000000000000 WAX       0     0     16
    

    This was a bug in the linker script for the FreeBSD BERI boot components, fixed in FreeBSD r294451: https://svnweb.freebsd.org/changeset/base/294451

    elfcopy should definitely clean up the empty output file on error though.

    (Also it would be nice if the error message could explicitly list what failed -- e.g. "invalid offset 0x78 in section 1 with alignment 16." But that's probably not feasible with the way libelf works.)

     
  • Ed Maste

    Ed Maste - 2016-02-29

    See ticket #292 for more on improving error messages.

     

Log in to post a comment.