Rich Felker
2014-02-17 07:19:15 UTC
There's been some interest in using pcc with musl libc on Linux (both
to compile the libc and for applications), which seems to be mostly or
fully working at this point; however, one major issue I just ran
across is that, when compiling position-independent code, all const
tables end up in .data rather than .text/.rodata. Naturally some such
tables belong in .data if they contain any non-null pointers, since
they'll be subject to relocations at load time by the dynamic linker.
However, for const data that does not contain pointers, having it in
.data is highly undesirable:
- It prevents the ability to detect bugs from applications attempting
to write to the data.
- It massively increases the commit charge needed.
In the case of musl libc.so, compiling with gcc gives only 1104 bytes
of .data, whereas compiling with pcc gives 180k of .data. The
difference is all constant tables: character properties, iconv mapping
tables, crypto constant tables, error strings, math coefficients,
state machines, etc.
Is there any easy way to fix this, or is it presently too difficult to
track whether the data object will contain relocations? A fix would be
much appreciated and would help make pcc a useful demo tool for us
(we're thinking of putting a jslinux image online with pcc and musl)
as well as a useful compiler for many of our users (who want something
BSD licensed that's not LLVM).
Rich
to compile the libc and for applications), which seems to be mostly or
fully working at this point; however, one major issue I just ran
across is that, when compiling position-independent code, all const
tables end up in .data rather than .text/.rodata. Naturally some such
tables belong in .data if they contain any non-null pointers, since
they'll be subject to relocations at load time by the dynamic linker.
However, for const data that does not contain pointers, having it in
.data is highly undesirable:
- It prevents the ability to detect bugs from applications attempting
to write to the data.
- It massively increases the commit charge needed.
In the case of musl libc.so, compiling with gcc gives only 1104 bytes
of .data, whereas compiling with pcc gives 180k of .data. The
difference is all constant tables: character properties, iconv mapping
tables, crypto constant tables, error strings, math coefficients,
state machines, etc.
Is there any easy way to fix this, or is it presently too difficult to
track whether the data object will contain relocations? A fix would be
much appreciated and would help make pcc a useful demo tool for us
(we're thinking of putting a jslinux image online with pcc and musl)
as well as a useful compiler for many of our users (who want something
BSD licensed that's not LLVM).
Rich