[PATCH] D32887: [ELF] Emit __ehdr_start when there is a segment containing program headers

Rafael Avila de Espindola via llvm-commits llvm-commits at lists.llvm.org
Tue May 9 13:56:05 PDT 2017


A comment more on the general problem:

We currently have two passes over the relocations. In the middle of
them, we assign addresses and if that finds out that there is room, we
allocate the headers.

The options I can see are
* Add an extra walk, but only if we know the link will fail. I *think*
  this was what the previous patch did. IMHO so far this is the best
  option.
* Report this particular undefined symbol with less information. I would
  save this as an easy last resort.
* Always define the symbol.
* Report undefined symbols in InputSection::relocateNonAlloc and
  InputSectionBase::relocate instead of the current location (requires a
  benchmark).
* Remember more information during the first scan, that seems the least
  desirable.
* Figure out earlier if we are going to allocate the headers. This is
  hard and just a conservative heuristic. For example, it is possible to
  construct a case where a PT_GNU_RELRO is not needed, but we don't know
  that until we known that a .got is not needed.

We already use the strategy of tentatively creating things and deleting
them if we find out we don't need them, so if we can make that work in
here that would be my preference.

Cheers,
Rafael


More information about the llvm-commits mailing list