This is the mail archive of the mailing list for the binutils project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Read-only data in ELF libraries may be remapped writable at runtime (upcoming NDSS'17 paper)

On 12/27/2016 09:48 PM, Cary Coutant wrote:
Nevertheless, I'd like to suggest that we're fixing the wrong problem.
Copy relocations have many problems, and I think we should focus more
on simply eliminating them entirely. The paper talks about that, but
only to the extent of using -fpic, which is overkill. It talks about
how Windows and macOS deal with the problem, but it overlooks some
other Unix platforms like HP-UX that do not use copy relocations at

On HP-UX, the compiler can be told to assume that any undefined data
symbol may be external to the load module, and generates an indirect
reference through the linkage table (aka, GOT). The linker is able to
rewrite the indirect reference as a direct reference if it determines
that the reference is within the same load module. The rewritten
sequence involves an extra register copy, but eliminates a much more
expensive memory load. The compiler can also make the opposite
assumption, and uses "#pragma external" to flag symbols that are known
to be external and should use the indirect sequence. All system header
files on HP-UX are decorated with these pragmas for all exported

A similar technique could be used on most other platforms that today
require copy relocations.

Indeed, this is exactly what I did for alpha-elf, back in 1996.

It's a bit of a shame that we didn't do the same thing for one of the several reincarnations of ppc64(le)-elf, nor the initial aarch64. Both have ISAs and ABIs that would not have suffered at all for having an indirect reference that relaxes to a direct reference iff the symbol turns out to be local.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]