audk/BaseTools/Source/C/GenFw
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
..
Elf32Convert.c BaseTools/GenFw RVCT: fix relocation processing of PT_DYNAMIC sections 2015-12-14 07:56:02 +00:00
Elf32Convert.h License header updated to match correct format. 2014-08-28 13:53:34 +00:00
Elf64Convert.c BaseTools/GenFw: remove ARM and RVCT references from ELF64 code 2015-09-24 19:35:10 +00:00
Elf64Convert.h License header updated to match correct format. 2014-08-28 13:53:34 +00:00
ElfConvert.c BaseTools: Update GenFw to support 4K alignment. 2015-06-29 03:17:34 +00:00
ElfConvert.h BaseTools: Update GenFw to support 4K alignment. 2015-06-29 03:17:34 +00:00
GNUmakefile Sync BaseTool trunk (version r2599) into EDKII BaseTools. 2013-08-23 02:18:16 +00:00
GenFw.c BaseTools/GenFw: add new option to not zero PE/COFF optional header fields 2015-11-11 06:30:42 +00:00
GenFw.h License header updated to match correct format. 2014-08-28 13:53:34 +00:00
Makefile Sync EDKII BaseTools to BaseTools project r1971 2010-05-18 05:04:32 +00:00
elf32.h Sync BaseTool trunk (version r2649) into EDKII BaseTools. 2014-01-27 05:23:15 +00:00
elf64.h Sync BaseTool trunk (version r2649) into EDKII BaseTools. 2014-01-27 05:23:15 +00:00
elf_common.h Sync BaseTool trunk (version r2649) into EDKII BaseTools. 2014-01-27 05:23:15 +00:00