aboutsummaryrefslogtreecommitdiff
path: root/include/coff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2021-04-16 22:29:05 +0930
committerAlan Modra <amodra@gmail.com>2021-04-16 23:21:44 +0930
commit6f8f6017a0c4e22c6417c597c31b0a937d148a39 (patch)
tree06fb2f4b8c73bbbc58ce2866e3d5e775ec37e070 /include/coff
parent768589d18042a55f0e1f77f466568a1c102ab099 (diff)
downloadgdb-6f8f6017a0c4e22c6417c597c31b0a937d148a39.zip
gdb-6f8f6017a0c4e22c6417c597c31b0a937d148a39.tar.gz
gdb-6f8f6017a0c4e22c6417c597c31b0a937d148a39.tar.bz2
PR27567, Linking PE files adds alignment section flags to executables
So don't set those flags for an executable. In the patch I also test DYNAMIC even though the PE bfd code doesn't appear to set it for dlls. I figure it doesn't hurt to include that flag too. PR 27567 bfd/ * coffcode.h (styp_to_sec_flags): Use an unsigned long styp_flags. (coff_write_object_contents): Pass bfd to COFF_ENCODE_ALIGNMENT, ignore alignment checks when return is false. Formatting. include/ * coff/internal.h (struct internal_scnhdr): Make s_flags unsigned long. * coff/pe.h (COFF_ENCODE_ALIGNMENT): Don't set align flags for an executable and return false. Do so for a relocatable object and evaluate to true. * coff/ti.h (COFF_ENCODE_ALIGNMENT): Add bfd arg and evaluate to true. (COFF_DECODE_ALIGNMENT): Formatting. * coff/z80.h (COFF_ENCODE_ALIGNMENT): Similarly. (COFF_DECODE_ALIGNMENT): Similarly.
Diffstat (limited to 'include/coff')
-rw-r--r--include/coff/internal.h2
-rw-r--r--include/coff/pe.h9
-rw-r--r--include/coff/ti.h5
-rw-r--r--include/coff/z80.h5
4 files changed, 13 insertions, 8 deletions
diff --git a/include/coff/internal.h b/include/coff/internal.h
index 90c901d..b09bb0f 100644
--- a/include/coff/internal.h
+++ b/include/coff/internal.h
@@ -407,7 +407,7 @@ struct internal_scnhdr
bfd_vma s_lnnoptr; /* file ptr to line numbers */
unsigned long s_nreloc; /* number of relocation entries */
unsigned long s_nlnno; /* number of line number entries*/
- long s_flags; /* flags */
+ unsigned long s_flags; /* flags */
unsigned char s_page; /* TI COFF load page */
};
diff --git a/include/coff/pe.h b/include/coff/pe.h
index a157812..d6e8469 100644
--- a/include/coff/pe.h
+++ b/include/coff/pe.h
@@ -105,9 +105,12 @@
#define IMAGE_SCN_ALIGN_8192BYTES IMAGE_SCN_ALIGN_POWER_CONST (13)
/* 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) <= 13 \
- ? (ALIGNMENT_POWER) : 13))
+#define COFF_ENCODE_ALIGNMENT(ABFD, SECTION, ALIGNMENT_POWER) \
+ (((ABFD)->flags & (EXEC_P | DYNAMIC)) != 0 ? false \
+ : ((SECTION).s_flags \
+ |= IMAGE_SCN_ALIGN_POWER_CONST ((ALIGNMENT_POWER) < 13 \
+ ? (ALIGNMENT_POWER) : 13), \
+ true))
#define COFF_DECODE_ALIGNMENT(X) \
IMAGE_SCN_ALIGN_POWER_NUM ((X) & IMAGE_SCN_ALIGN_POWER_BIT_MASK)
diff --git a/include/coff/ti.h b/include/coff/ti.h
index 5d242d1..e51cf96 100644
--- a/include/coff/ti.h
+++ b/include/coff/ti.h
@@ -88,9 +88,10 @@ struct external_filehdr
#define COFF_ALIGN_IN_SECTION_HEADER 1
#define COFF_ALIGN_IN_S_FLAGS 1
/* requires a power-of-two argument */
-#define COFF_ENCODE_ALIGNMENT(S,X) ((S).s_flags |= (((unsigned)(X)&0xF)<<8))
+#define COFF_ENCODE_ALIGNMENT(B,S,X) \
+ ((S).s_flags |= (((unsigned) (X) & 0xF) << 8), true)
/* result is a power of two */
-#define COFF_DECODE_ALIGNMENT(X) (((X)>>8)&0xF)
+#define COFF_DECODE_ALIGNMENT(X) (((X) >> 8) & 0xF)
#define COFF0_P(ABFD) (bfd_coff_filhsz(ABFD) == FILHSZ_V0)
#define COFF2_P(ABFD) (bfd_coff_scnhsz(ABFD) != SCNHSZ_V01)
diff --git a/include/coff/z80.h b/include/coff/z80.h
index 1ba8e45..1fd94fe 100644
--- a/include/coff/z80.h
+++ b/include/coff/z80.h
@@ -35,9 +35,10 @@
#define COFF_ALIGN_IN_S_FLAGS 1
#define F_ALGNMASK 0x0F00
/* requires a power-of-two argument */
-#define COFF_ENCODE_ALIGNMENT(S,X) ((S).s_flags |= (((unsigned)(X)&0xF)<<8))
+#define COFF_ENCODE_ALIGNMENT(B,S,X) \
+ ((S).s_flags |= (((unsigned) (X) & 0xF) << 8), true)
/* result is a power of two */
-#define COFF_DECODE_ALIGNMENT(X) (((X)>>8)&0xF)
+#define COFF_DECODE_ALIGNMENT(X) (((X) >> 8) & 0xF)
#define Z80MAGIC 0x805A