aboutsummaryrefslogtreecommitdiff
path: root/include/coff
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/coff
parentb76bc5d54e36f15efd954898d9aa075c2bea02dd (diff)
downloadbinutils-5be87c8fa74c9ae6684bea571b4157ad1966d008.zip
binutils-5be87c8fa74c9ae6684bea571b4157ad1966d008.tar.gz
binutils-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/coff')
-rw-r--r--include/coff/pe.h5
1 files changed, 4 insertions, 1 deletions
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. */