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
The offending section is this one, which claims 16-byte alignment but is at an offset of 0x78:
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.)
See ticket #292 for more on improving error messages.