aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorJan Beulich <jbeulich@novell.com>2017-11-13 12:26:12 +0100
committerJan Beulich <jbeulich@suse.com>2017-11-13 12:26:12 +0100
commit5be87c8fa74c9ae6684bea571b4157ad1966d008 (patch)
tree03ab623efa8dc04c95e82d4c6b05b9eb3ab346c4 /include
parentb76bc5d54e36f15efd954898d9aa075c2bea02dd (diff)
downloadgdb-5be87c8fa74c9ae6684bea571b4157ad1966d008.zip
gdb-5be87c8fa74c9ae6684bea571b4157ad1966d008.tar.gz
gdb-5be87c8fa74c9ae6684bea571b4157ad1966d008.tar.bz2
PE: don't corrupt section flags when linking from ELF objects
Linking EFI executables from ELF object files can result in corrupted COFF section flags if the section's alignment is too high. Issue a diagnostic in that case, erroring out if this is not a final link, and make sure only in-range values get written to the output image. While doing this also make tic80 use the generic alignment macros instead of custom #ifdef-ary. No testsuite regressions for the range of COFF/PE targets that actually cross-build in the first place on x86-64-linux.
Diffstat (limited to 'include')
-rw-r--r--include/ChangeLog6
-rw-r--r--include/coff/pe.h5
2 files changed, 10 insertions, 1 deletions
diff --git a/include/ChangeLog b/include/ChangeLog
index dc320cb..a6e3ebc 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,3 +1,9 @@
+2017-11-13 Jan Beulich <jbeulich@suse.com>
+
+ * coff/pe.h (COFF_ENCODE_ALIGNMENT): Cap value to maximum one
+ representable.
+ (COFF_DECODE_ALIGNMENT): Define.
+
2017-11-09 Tamar Christina <tamar.christina@arm.com>
* opcode/aarch64.h (AARCH64_ARCH_V8_4): Enable DOTPROD.
diff --git a/include/coff/pe.h b/include/coff/pe.h
index f51ceed..5239916 100644
--- a/include/coff/pe.h
+++ b/include/coff/pe.h
@@ -104,7 +104,10 @@
/* Encode alignment power into IMAGE_SCN_ALIGN bits of s_flags. */
#define COFF_ENCODE_ALIGNMENT(SECTION, ALIGNMENT_POWER) \
- ((SECTION).s_flags |= IMAGE_SCN_ALIGN_POWER_CONST ((ALIGNMENT_POWER)))
+ ((SECTION).s_flags |= IMAGE_SCN_ALIGN_POWER_CONST ((ALIGNMENT_POWER) <= 13 \
+ ? (ALIGNMENT_POWER) : 13))
+#define COFF_DECODE_ALIGNMENT(X) \
+ IMAGE_SCN_ALIGN_POWER_NUM ((X) & IMAGE_SCN_ALIGN_POWER_BIT_MASK)
#define IMAGE_SCN_LNK_NRELOC_OVFL 0x01000000 /* Section contains extended relocations. */
#define IMAGE_SCN_MEM_NOT_CACHED 0x04000000 /* Section is not cachable. */