[PATCH] D53003: [ELF] Fix link failure with Android compressed relocation support.

Ryan Prichard via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 8 18:20:46 PDT 2018


rprichard added a comment.

Adding zero padding to the end of the SHT_ANDROID_REL[A] section shouldn't be a problem. It looks like the original Android relocation_packer tool <https://android.googlesource.com/platform/bionic/+/pie-dev/tools/relocation_packer/src/elf_file.cc> left up to a page of zero bytes at the end of the packed section, and the decoders in Bionic <https://android.googlesource.com/platform/bionic/+/cbc80ba9d839675a0c4891e2ab33f39ba51b04b2/linker/linker_reloc_iterators.h#66> and LLVM <https://github.com/llvm-mirror/llvm/blob/78fee6e56c34dd0b1052534b2b9d39f2574303ad/lib/Object/ELF.cpp#L341> would ignore the trailing bytes. relocation_packer doesn't loop stabilizing SLEB sizes, but I think it didn't need to. When it shrunk a .rel[a].dyn section, it apparently only shrunk the section by a multiple of the page size. It left the virtual addresses of the sections following .rel[a].dyn unchanged, and I don't think it adjusted the offset/addend values of the relocations.

FWIW: I fixed a similar issue in the LLVM assembler with the exception table: https://reviews.llvm.org/D42722

I wonder if a non-contrived input could require more than 10 rounds to converge. It seems unlikely to happen, at least.

This change seems fine to me.



================
Comment at: test/ELF/pack-dyn-relocs-loop.s:12
+
+// This test is very sensitive to the exact section sizes abd offsets,
+// so check that they don't change.
----------------
s/abd/and/ ?


Repository:
  rLLD LLVM Linker

https://reviews.llvm.org/D53003





More information about the llvm-commits mailing list