audk/BaseTools/Source/C
Ard Biesheuvel 088dc24508 BaseTools/GenFw RVCT: fix relocation processing of PT_DYNAMIC sections
Unlike GNU ld, which can be instructed to emit symbol based static
relocations into fully linked binaries using the --emit-relocs command
line switch, the RVCT armlink tool can only emit dynamic relocations
into the PT_DYNAMIC segment.

This has two consequences
. we can only identify absolute relocations, so there is no way to fix
  up relative relocations between sections, or check their validity in
  the PE/COFF layout
. the r_offset fields of the PT_DYNAMIC DT_REL entries are relative
  either to the base of the image or to any of its segments but *not* to
  the base of the input section that contains the location they refer
  to, and converting them to PE/COFF image offsets is non-trivial unless
  the sections are laid out in the same way in the ELF and PE/COFF
  versions of the binary.

There is really only one way to deal with this, and that is to require
that the ELF and PE/COFF versions of the binary are identical in memory.
So enforce that in the code.

Also, fix the utterly broken relocation fixup code that dereferences
ELF32_R_SYM(r_info) both as a 1-based program header index and a 0-based
section header index. If this code ever produced working binaries, it
was purely by chance.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Liming Gao <liming.gao@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19236 6f19259b-4bc3-4df7-8a09-765794883524
2015-12-14 07:56:02 +00:00
..
BootSectImage BootSectImage.exe, EfiLdrImage.exe and Split.exe tools have incorrect output from the --version option. 2014-08-25 20:06:55 +00:00
Common BaseTools/PeCoffLoader: fix handling of ARM MOVW/MOVT instruction relocs 2015-10-09 18:55:28 +00:00
EfiLdrImage License header updated to match correct format. 2014-08-28 13:53:34 +00:00
EfiRom License header updated to match correct format. 2014-08-28 13:53:34 +00:00
GenBootSector License header updated to match correct format. 2014-08-28 13:53:34 +00:00
GenCrc32 License header updated to match correct format. 2014-08-28 13:53:34 +00:00
GenFfs BaseTools: use GUID identifiable section for FFS alignment padding 2015-07-27 13:50:19 +00:00
GenFv BaseTools: Enhance GenFv Tool to report error message 2015-12-07 09:04:39 +00:00
GenFw BaseTools/GenFw RVCT: fix relocation processing of PT_DYNAMIC sections 2015-12-14 07:56:02 +00:00
GenPage License header updated to match correct format. 2014-08-28 13:53:34 +00:00
GenSec License header updated to match correct format. 2014-08-28 13:53:34 +00:00
GenVtf License header updated to match correct format. 2014-08-28 13:53:34 +00:00
GnuGenBootSector License header updated to match correct format. 2014-08-28 13:53:34 +00:00
Include Revert the change in r19137. 2015-12-07 09:01:44 +00:00
LzmaCompress BaseTools: Fix build on FreeBSD and allow use of non-gcc system compiler 2015-07-08 01:06:25 +00:00
Makefiles BaseTools: Fix build on FreeBSD and allow use of non-gcc system compiler 2015-07-08 01:06:25 +00:00
PyEfiCompressor License header updated to match correct format. 2014-08-28 13:53:34 +00:00
PyUtility License header updated to match correct format. 2014-08-28 13:53:34 +00:00
Split BaseTools:remove the redundant directories for '-f' with absolute path. 2015-10-27 03:29:50 +00:00
TianoCompress License header updated to match correct format. 2014-08-28 13:53:34 +00:00
VfrCompile BaseTools: Fix two warning reported in the make phase. 2015-11-17 07:40:00 +00:00
VolInfo BaseTools: Fix two warning reported in the make phase. 2015-11-17 07:40:00 +00:00
GNUmakefile BaseTools: add ARCH detection for AARCH64 and ARM 2015-08-12 05:22:49 +00:00
Makefile Fix nmake cleanall bugs. 2014-08-25 05:00:34 +00:00