LTO and libelf (and FreeBSD)
Steve Kargl
sgk@troutmask.apl.washington.edu
Mon May 24 08:23:00 GMT 2010
Kai,
I tested your patch posted here:
http://gcc.gnu.org/ml/gcc/2010-05/msg00445.html
to address the issue
% cat x.c
int main() { }
% gccvs -flto x.c
% gccvs -fwhopr x.c
lto1: fatal error: elf_update() failed: Layout constraint violation
compilation terminated.
lto-wrapper: gccvs returned 1 exit status
which is an appear imcompatibility between FreeBSD's libelf and
gcc's lto. My testing shows that your patch fixes all the problems
I've observed.
I do however share your concern that gcc may not be following the
ELF spec. Everything that I can find suggests that the alignment
of a section must be the same for all data. The statements on
the web that I've found are of the form:
When deciding how to build the output file, elf_update obeys the
alignments of individual data buffers to create output sections.
A section's most strictly aligned data buffer controls the section's
alignment. The library also inserts padding between buffers, as
necessary, to ensure the proper alignment of each buffer.
It's unclear to me whether FreeBSD libelf is too strict in its
interpretation of the above or whether gcc is to too loose in
its interpretation of what alignment of data means.
--
Steve
More information about the Gcc
mailing list