summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2018-12-18 19:03:51 +1030
committerAlan Modra <amodra@gmail.com>2018-12-18 23:49:48 +1030
commit2d5d5a8f0a8b5a03454bf168b7fa7024bb1ebbd8 (patch)
treed04b941775ee98f096c27b5df2fa8da735a1b470
parenta529dcc854968b7f6ad766c714650011dc361382 (diff)
downloadbinutils-gdb-2d5d5a8f0a8b5a03454bf168b7fa7024bb1ebbd8.tar.gz
Include bfd_stdint.h in bfd.h
This patch adds bfd_stdint.h to bfd.h, so that BFD can use size_t where appropriate in function parameters and return values. I also tidy a few other cases where headers are included twice. bfd/ * Makefile.am (bfdinclude_HEADERS): Add bfd_stdint.h. (BFD_H_DEPS): Add include/diagnostics.h. (LOCAL_H_DEPS): Add bfd_stdint.h. * bfd-in.h: Include bfd_stdint.h. * arc-plt.h: Don't include stdint.h. * coff-rs6000.c: Likewise. * coff64-rs6000.c: Likewise. * elfxx-riscv.c: Likewise. * cache.c: Don't include bfd_stdint.h. * elf32-arm.c: Likewise. * elf32-avr.c: Likewise. * elf32-nds32.c: Likewise. * elf32-rl78.c: Likewise. * elf32-rx.c: Likewise. * elf32-wasm32.c: Likewise. * elf64-nfp.c: Likewise. * elflink.c: Likewise. * elfnn-aarch64.c: Likewise. * elfnn-ia64.c: Likewise. * elfxx-ia64.c: Likewise. * elfxx-x86.h: Likewise. * wasm-module.c: Likewise, and don't include sysdep.h twice. * elf-nacl.h: Don't include bfd.h. * mach-o.h: Likewise. * elfxx-aarch64.c: Include bfd.h and elf-bfd.h. * elfxx-aarch64.h: Don't include bfd.h, elf-bfd.h or stdint.h. * mach-o-aarch64.c: Include mach-o.h later. * mach-o-arm.c: Likewise. * mach-o-i386.c: Likewise. * mach-o-x86-64.c: Likewise. * mach-o.c: Likewise. * sysdep.h: Don't include ansidecl.h or sys/stat.h. * Makefile.in: Regenerate. * bfd-in2.h: Regenerate. opcodes/ * arm-dis.c: Include bfd.h. * aarch64-opc.c: Include bfd_stdint.h rather than stdint.h. * csky-dis.c: Likewise. * nds32-asm.c: Likewise. * riscv-dis.c: Likewise. * s12z-dis.c: Likewise. * wasm32-dis.c: Likewise.
-rw-r--r--bfd/ChangeLog37
-rw-r--r--bfd/Makefile.am6
-rw-r--r--bfd/Makefile.in12
-rw-r--r--bfd/arc-plt.h2
-rw-r--r--bfd/bfd-in.h1
-rw-r--r--bfd/bfd-in2.h1
-rw-r--r--bfd/cache.c1
-rw-r--r--bfd/coff-rs6000.c1
-rw-r--r--bfd/coff64-rs6000.c1
-rw-r--r--bfd/elf-nacl.h2
-rw-r--r--bfd/elf32-arm.c1
-rw-r--r--bfd/elf32-avr.c1
-rw-r--r--bfd/elf32-nds32.c2
-rw-r--r--bfd/elf32-rl78.c1
-rw-r--r--bfd/elf32-rx.c1
-rw-r--r--bfd/elf32-wasm32.c1
-rwxr-xr-xbfd/elf64-nfp.c1
-rw-r--r--bfd/elflink.c1
-rw-r--r--bfd/elfnn-aarch64.c1
-rw-r--r--bfd/elfnn-ia64.c1
-rw-r--r--bfd/elfxx-aarch64.c2
-rw-r--r--bfd/elfxx-aarch64.h4
-rw-r--r--bfd/elfxx-ia64.c1
-rw-r--r--bfd/elfxx-riscv.c1
-rw-r--r--bfd/elfxx-x86.h1
-rw-r--r--bfd/mach-o-aarch64.c2
-rw-r--r--bfd/mach-o-arm.c2
-rw-r--r--bfd/mach-o-i386.c2
-rw-r--r--bfd/mach-o-x86-64.c2
-rw-r--r--bfd/mach-o.c2
-rw-r--r--bfd/mach-o.h1
-rw-r--r--bfd/sysdep.h3
-rw-r--r--bfd/wasm-module.c2
-rw-r--r--opcodes/ChangeLog10
-rw-r--r--opcodes/aarch64-opc.c2
-rw-r--r--opcodes/arm-dis.c1
-rw-r--r--opcodes/csky-dis.c2
-rw-r--r--opcodes/nds32-asm.c2
-rw-r--r--opcodes/riscv-dis.c2
-rw-r--r--opcodes/s12z-dis.c2
-rw-r--r--opcodes/wasm32-dis.c2
41 files changed, 72 insertions, 51 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 8fcdb59648b..348559306fb 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,5 +1,42 @@
2018-12-18 Alan Modra <amodra@gmail.com>
+ * Makefile.am (bfdinclude_HEADERS): Add bfd_stdint.h.
+ (BFD_H_DEPS): Add include/diagnostics.h.
+ (LOCAL_H_DEPS): Add bfd_stdint.h.
+ * bfd-in.h: Include bfd_stdint.h.
+ * arc-plt.h: Don't include stdint.h.
+ * coff-rs6000.c: Likewise.
+ * coff64-rs6000.c: Likewise.
+ * elfxx-riscv.c: Likewise.
+ * cache.c: Don't include bfd_stdint.h.
+ * elf32-arm.c: Likewise.
+ * elf32-avr.c: Likewise.
+ * elf32-nds32.c: Likewise.
+ * elf32-rl78.c: Likewise.
+ * elf32-rx.c: Likewise.
+ * elf32-wasm32.c: Likewise.
+ * elf64-nfp.c: Likewise.
+ * elflink.c: Likewise.
+ * elfnn-aarch64.c: Likewise.
+ * elfnn-ia64.c: Likewise.
+ * elfxx-ia64.c: Likewise.
+ * elfxx-x86.h: Likewise.
+ * wasm-module.c: Likewise, and don't include sysdep.h twice.
+ * elf-nacl.h: Don't include bfd.h.
+ * mach-o.h: Likewise.
+ * elfxx-aarch64.c: Include bfd.h and elf-bfd.h.
+ * elfxx-aarch64.h: Don't include bfd.h, elf-bfd.h or stdint.h.
+ * mach-o-aarch64.c: Include mach-o.h later.
+ * mach-o-arm.c: Likewise.
+ * mach-o-i386.c: Likewise.
+ * mach-o-x86-64.c: Likewise.
+ * mach-o.c: Likewise.
+ * sysdep.h: Don't include ansidecl.h or sys/stat.h.
+ * Makefile.in: Regenerate.
+ * bfd-in2.h: Regenerate.
+
+2018-12-18 Alan Modra <amodra@gmail.com>
+
PR 23980
* elf32-i386.c (elf_i386_relocate_section): Exit with wrong format
error rather than asserting input file is as expected.
diff --git a/bfd/Makefile.am b/bfd/Makefile.am
index 2626ceb0a59..3d606282627 100644
--- a/bfd/Makefile.am
+++ b/bfd/Makefile.am
@@ -33,7 +33,7 @@ bfdlibdir = @bfdlibdir@
bfdincludedir = @bfdincludedir@
bfdlib_LTLIBRARIES = libbfd.la
bfdinclude_HEADERS = $(BFD_H) $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h \
- $(INCDIR)/bfdlink.h $(INCDIR)/diagnostics.h
+ bfd_stdint.h $(INCDIR)/diagnostics.h $(INCDIR)/bfdlink.h
else !INSTALL_LIBBFD
# Empty these so that the respective installation directories will not be created.
bfdlibdir =
@@ -873,8 +873,8 @@ pex64igen.c: peXXigen.c
$(SED) -e s/XX/pex64/g < $(srcdir)/peXXigen.c > pex64igen.new
mv -f pex64igen.new pex64igen.c
-BFD_H_DEPS= $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h
-LOCAL_H_DEPS= libbfd.h sysdep.h config.h
+BFD_H_DEPS= $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h $(INCDIR)/diagnostics.h
+LOCAL_H_DEPS= libbfd.h sysdep.h config.h bfd_stdint.h
$(BFD32_LIBS) \
$(BFD64_LIBS) \
$(ALL_MACHINES) \
diff --git a/bfd/Makefile.in b/bfd/Makefile.in
index e63d63ab9ea..40342442a32 100644
--- a/bfd/Makefile.in
+++ b/bfd/Makefile.in
@@ -248,8 +248,8 @@ am__can_run_installinfo = \
*) (install-info --version) >/dev/null 2>&1;; \
esac
am__bfdinclude_HEADERS_DIST = $(INCDIR)/plugin-api.h bfd.h \
- $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h $(INCDIR)/bfdlink.h \
- $(INCDIR)/diagnostics.h
+ $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h bfd_stdint.h \
+ $(INCDIR)/diagnostics.h $(INCDIR)/bfdlink.h
HEADERS = $(bfdinclude_HEADERS)
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive
@@ -468,8 +468,8 @@ libbfd_la_LDFLAGS = $(am__append_1) -release `cat libtool-soversion` \
@INSTALL_LIBBFD_FALSE@bfdinclude_HEADERS = $(am__append_2)
@INSTALL_LIBBFD_TRUE@bfdinclude_HEADERS = $(BFD_H) \
@INSTALL_LIBBFD_TRUE@ $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h \
-@INSTALL_LIBBFD_TRUE@ $(INCDIR)/bfdlink.h \
-@INSTALL_LIBBFD_TRUE@ $(INCDIR)/diagnostics.h $(am__append_2)
+@INSTALL_LIBBFD_TRUE@ bfd_stdint.h $(INCDIR)/diagnostics.h \
+@INSTALL_LIBBFD_TRUE@ $(INCDIR)/bfdlink.h $(am__append_2)
@INSTALL_LIBBFD_FALSE@rpath_bfdlibdir = @bfdlibdir@
@INSTALL_LIBBFD_FALSE@noinst_LTLIBRARIES = libbfd.la
@@ -1146,8 +1146,8 @@ libbfd_la_LIBADD = `cat ofiles` @SHARED_LIBADD@ $(LIBDL) $(ZLIB)
# everything else starts using libtool. FIXME.
noinst_LIBRARIES = libbfd.a
libbfd_a_SOURCES =
-BFD_H_DEPS = $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h
-LOCAL_H_DEPS = libbfd.h sysdep.h config.h
+BFD_H_DEPS = $(INCDIR)/ansidecl.h $(INCDIR)/symcat.h $(INCDIR)/diagnostics.h
+LOCAL_H_DEPS = libbfd.h sysdep.h config.h bfd_stdint.h
BFD_H_FILES = bfd-in.h init.c opncls.c libbfd.c \
bfdio.c bfdwin.c section.c archures.c reloc.c \
syms.c bfd.c archive.c corefile.c targets.c format.c \
diff --git a/bfd/arc-plt.h b/bfd/arc-plt.h
index 2f4ba8604b0..994b4882e95 100644
--- a/bfd/arc-plt.h
+++ b/bfd/arc-plt.h
@@ -22,8 +22,6 @@
#ifndef ARC_PLT_H
#define ARC_PLT_H
-#include <stdint.h>
-
/* Instructions appear in memory as a sequence of half-words (16 bit);
individual half-words are represented on the target in target byte order.
We use 'unsigned short' on the host to represent the PLT templates,
diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h
index 47b60bcfbff..5657d93b7ef 100644
--- a/bfd/bfd-in.h
+++ b/bfd/bfd-in.h
@@ -34,6 +34,7 @@ extern "C" {
#include "ansidecl.h"
#include "symcat.h"
+#include "bfd_stdint.h"
#include "diagnostics.h"
#include <stdarg.h>
#include <sys/stat.h>
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 6d92c51cb97..ab71c350f7d 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -41,6 +41,7 @@ extern "C" {
#include "ansidecl.h"
#include "symcat.h"
+#include "bfd_stdint.h"
#include "diagnostics.h"
#include <stdarg.h>
#include <sys/stat.h>
diff --git a/bfd/cache.c b/bfd/cache.c
index faee6779f8f..17c84cccda2 100644
--- a/bfd/cache.c
+++ b/bfd/cache.c
@@ -44,7 +44,6 @@ SUBSECTION
#include "bfd.h"
#include "libbfd.h"
#include "libiberty.h"
-#include "bfd_stdint.h"
#ifdef HAVE_MMAP
#include <sys/mman.h>
diff --git a/bfd/coff-rs6000.c b/bfd/coff-rs6000.c
index edff50daaaf..65ae05cdcd5 100644
--- a/bfd/coff-rs6000.c
+++ b/bfd/coff-rs6000.c
@@ -114,7 +114,6 @@ extern int rs6000coff_core_file_failing_signal (bfd *abfd);
#define bfd_pe_print_pdata NULL
#endif
-#include <stdint.h>
#include "coffcode.h"
/* The main body of code is in coffcode.h. */
diff --git a/bfd/coff64-rs6000.c b/bfd/coff64-rs6000.c
index 928a23d4f88..6e52347624b 100644
--- a/bfd/coff64-rs6000.c
+++ b/bfd/coff64-rs6000.c
@@ -278,7 +278,6 @@ extern int rs6000coff_core_file_failing_signal
#define bfd_pe_print_pdata NULL
#endif
-#include <stdint.h>
#include "coffcode.h"
/* For XCOFF64, the effective width of symndx changes depending on
diff --git a/bfd/elf-nacl.h b/bfd/elf-nacl.h
index 8ca06183149..1b691a313b3 100644
--- a/bfd/elf-nacl.h
+++ b/bfd/elf-nacl.h
@@ -16,8 +16,6 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
-#include "bfd.h"
-
bfd_boolean nacl_modify_segment_map (bfd *, struct bfd_link_info *);
bfd_boolean nacl_modify_program_headers (bfd *, struct bfd_link_info *);
void nacl_final_write_processing (bfd *, bfd_boolean linker);
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index 5adec5e4731..9fda98edd85 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -22,7 +22,6 @@
#include <limits.h>
#include "bfd.h"
-#include "bfd_stdint.h"
#include "libiberty.h"
#include "libbfd.h"
#include "elf-bfd.h"
diff --git a/bfd/elf32-avr.c b/bfd/elf32-avr.c
index 13e28d8a1ed..527149c67bc 100644
--- a/bfd/elf32-avr.c
+++ b/bfd/elf32-avr.c
@@ -25,7 +25,6 @@
#include "elf-bfd.h"
#include "elf/avr.h"
#include "elf32-avr.h"
-#include "bfd_stdint.h"
/* Enable debugging printout at stdout with this variable. */
static bfd_boolean debug_relax = FALSE;
diff --git a/bfd/elf32-nds32.c b/bfd/elf32-nds32.c
index 184cf320f7c..c7e15190cd5 100644
--- a/bfd/elf32-nds32.c
+++ b/bfd/elf32-nds32.c
@@ -22,12 +22,10 @@
#include "sysdep.h"
#include "bfd.h"
-#include "bfd_stdint.h"
#include "bfdlink.h"
#include "libbfd.h"
#include "elf-bfd.h"
#include "libiberty.h"
-#include "bfd_stdint.h"
#include "elf/nds32.h"
#include "opcode/nds32.h"
#include "elf32-nds32.h"
diff --git a/bfd/elf32-rl78.c b/bfd/elf32-rl78.c
index e072b1a96ef..3a96f41343e 100644
--- a/bfd/elf32-rl78.c
+++ b/bfd/elf32-rl78.c
@@ -20,7 +20,6 @@
#include "sysdep.h"
#include "bfd.h"
-#include "bfd_stdint.h"
#include "libbfd.h"
#include "elf-bfd.h"
#include "elf/rl78.h"
diff --git a/bfd/elf32-rx.c b/bfd/elf32-rx.c
index ddcf5e980fa..68fac291b8f 100644
--- a/bfd/elf32-rx.c
+++ b/bfd/elf32-rx.c
@@ -20,7 +20,6 @@
#include "sysdep.h"
#include "bfd.h"
-#include "bfd_stdint.h"
#include "libbfd.h"
#include "elf-bfd.h"
#include "elf/rx.h"
diff --git a/bfd/elf32-wasm32.c b/bfd/elf32-wasm32.c
index 9fc48de6d65..d4e54ca266c 100644
--- a/bfd/elf32-wasm32.c
+++ b/bfd/elf32-wasm32.c
@@ -22,7 +22,6 @@
#include "bfd.h"
#include "libbfd.h"
#include "elf-bfd.h"
-#include "bfd_stdint.h"
#include "libiberty.h"
#include "elf/wasm32.h"
diff --git a/bfd/elf64-nfp.c b/bfd/elf64-nfp.c
index 3cdda3d36b9..e0435357238 100755
--- a/bfd/elf64-nfp.c
+++ b/bfd/elf64-nfp.c
@@ -24,7 +24,6 @@
#include "libbfd.h"
#include "elf-bfd.h"
#include "elf/nfp.h"
-#include "bfd_stdint.h"
static bfd_reloc_status_type
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 8992a5016f7..f5b411bd628 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -20,7 +20,6 @@
#include "sysdep.h"
#include "bfd.h"
-#include "bfd_stdint.h"
#include "bfdlink.h"
#include "libbfd.h"
#define ARCH_SIZE 0
diff --git a/bfd/elfnn-aarch64.c b/bfd/elfnn-aarch64.c
index 083f90b57de..8b5124b4c0e 100644
--- a/bfd/elfnn-aarch64.c
+++ b/bfd/elfnn-aarch64.c
@@ -139,7 +139,6 @@
#include "bfd.h"
#include "libiberty.h"
#include "libbfd.h"
-#include "bfd_stdint.h"
#include "elf-bfd.h"
#include "bfdlink.h"
#include "objalloc.h"
diff --git a/bfd/elfnn-ia64.c b/bfd/elfnn-ia64.c
index e6551df2046..56572d3d072 100644
--- a/bfd/elfnn-ia64.c
+++ b/bfd/elfnn-ia64.c
@@ -27,7 +27,6 @@
#include "elf/ia64.h"
#include "objalloc.h"
#include "hashtab.h"
-#include "bfd_stdint.h"
#include "elfxx-ia64.h"
#define ARCH_SIZE NN
diff --git a/bfd/elfxx-aarch64.c b/bfd/elfxx-aarch64.c
index b8a541a9dda..e3b6ef6d5fd 100644
--- a/bfd/elfxx-aarch64.c
+++ b/bfd/elfxx-aarch64.c
@@ -19,6 +19,8 @@
see <http://www.gnu.org/licenses/>. */
#include "sysdep.h"
+#include "bfd.h"
+#include "elf-bfd.h"
#include "elfxx-aarch64.h"
#include <stdarg.h>
#include <string.h>
diff --git a/bfd/elfxx-aarch64.h b/bfd/elfxx-aarch64.h
index 301af73e3ec..0aa536a4bfb 100644
--- a/bfd/elfxx-aarch64.h
+++ b/bfd/elfxx-aarch64.h
@@ -18,10 +18,6 @@
along with this program; see the file COPYING3. If not,
see <http://www.gnu.org/licenses/>. */
-#include "bfd.h"
-#include "elf-bfd.h"
-#include "stdint.h"
-
/* Take the PAGE component of an address or offset. */
#define PG(x) ((x) & ~ (bfd_vma) 0xfff)
#define PG_OFFSET(x) ((x) & (bfd_vma) 0xfff)
diff --git a/bfd/elfxx-ia64.c b/bfd/elfxx-ia64.c
index 290dcd8e539..2c96f05da83 100644
--- a/bfd/elfxx-ia64.c
+++ b/bfd/elfxx-ia64.c
@@ -27,7 +27,6 @@
#include "elf/ia64.h"
#include "objalloc.h"
#include "hashtab.h"
-#include "bfd_stdint.h"
#include "elfxx-ia64.h"
/* THE RULES for all the stuff the linker creates --
diff --git a/bfd/elfxx-riscv.c b/bfd/elfxx-riscv.c
index a88c7fa2e76..d92b2738f3d 100644
--- a/bfd/elfxx-riscv.c
+++ b/bfd/elfxx-riscv.c
@@ -29,7 +29,6 @@
#include "libiberty.h"
#include "elfxx-riscv.h"
#include "safe-ctype.h"
-#include <stdint.h>
#define MINUS_ONE ((bfd_vma)0 - 1)
diff --git a/bfd/elfxx-x86.h b/bfd/elfxx-x86.h
index d153623d3e8..2415987d32b 100644
--- a/bfd/elfxx-x86.h
+++ b/bfd/elfxx-x86.h
@@ -23,7 +23,6 @@
#include "bfdlink.h"
#include "libbfd.h"
#include "elf-bfd.h"
-#include "bfd_stdint.h"
#include "hashtab.h"
#define PLT_CIE_LENGTH 20
diff --git a/bfd/mach-o-aarch64.c b/bfd/mach-o-aarch64.c
index 7013d26da1a..018ac2e12ef 100644
--- a/bfd/mach-o-aarch64.c
+++ b/bfd/mach-o-aarch64.c
@@ -19,10 +19,10 @@
MA 02110-1301, USA. */
#include "sysdep.h"
-#include "mach-o.h"
#include "bfd.h"
#include "libbfd.h"
#include "libiberty.h"
+#include "mach-o.h"
#include "mach-o/arm64.h"
#define bfd_mach_o_object_p bfd_mach_o_arm64_object_p
diff --git a/bfd/mach-o-arm.c b/bfd/mach-o-arm.c
index 738b2f1643e..5182c97f8bc 100644
--- a/bfd/mach-o-arm.c
+++ b/bfd/mach-o-arm.c
@@ -19,10 +19,10 @@
MA 02110-1301, USA. */
#include "sysdep.h"
-#include "mach-o.h"
#include "bfd.h"
#include "libbfd.h"
#include "libiberty.h"
+#include "mach-o.h"
#include "mach-o/arm.h"
#define bfd_mach_o_object_p bfd_mach_o_arm_object_p
diff --git a/bfd/mach-o-i386.c b/bfd/mach-o-i386.c
index 4918e5e6da4..db92e5d10ae 100644
--- a/bfd/mach-o-i386.c
+++ b/bfd/mach-o-i386.c
@@ -19,10 +19,10 @@
MA 02110-1301, USA. */
#include "sysdep.h"
-#include "mach-o.h"
#include "bfd.h"
#include "libbfd.h"
#include "libiberty.h"
+#include "mach-o.h"
#include "mach-o/reloc.h"
#define bfd_mach_o_object_p bfd_mach_o_i386_object_p
diff --git a/bfd/mach-o-x86-64.c b/bfd/mach-o-x86-64.c
index 9ee93a4ffb9..153a85cedad 100644
--- a/bfd/mach-o-x86-64.c
+++ b/bfd/mach-o-x86-64.c
@@ -19,10 +19,10 @@
MA 02110-1301, USA. */
#include "sysdep.h"
-#include "mach-o.h"
#include "bfd.h"
#include "libbfd.h"
#include "libiberty.h"
+#include "mach-o.h"
#include "mach-o/x86-64.h"
#define bfd_mach_o_object_p bfd_mach_o_x86_64_object_p
diff --git a/bfd/mach-o.c b/bfd/mach-o.c
index 51217158ce1..11e946c47d3 100644
--- a/bfd/mach-o.c
+++ b/bfd/mach-o.c
@@ -19,10 +19,10 @@
MA 02110-1301, USA. */
#include "sysdep.h"
-#include "mach-o.h"
#include "bfd.h"
#include "libbfd.h"
#include "libiberty.h"
+#include "mach-o.h"
#include "aout/stab_gnu.h"
#include "mach-o/reloc.h"
#include "mach-o/external.h"
diff --git a/bfd/mach-o.h b/bfd/mach-o.h
index 61428d6a3ae..97547a53de7 100644
--- a/bfd/mach-o.h
+++ b/bfd/mach-o.h
@@ -21,7 +21,6 @@
#ifndef _BFD_MACH_O_H_
#define _BFD_MACH_O_H_
-#include "bfd.h"
#include "mach-o/loader.h"
#include "mach-o/external.h"
diff --git a/bfd/sysdep.h b/bfd/sysdep.h
index bc7dbcf6c34..7152d77be1e 100644
--- a/bfd/sysdep.h
+++ b/bfd/sysdep.h
@@ -28,15 +28,12 @@
#include "config.h"
-#include "ansidecl.h"
-
#ifdef HAVE_STDDEF_H
#include <stddef.h>
#endif
#include <stdio.h>
#include <sys/types.h>
-#include <sys/stat.h>
#include <errno.h>
#if !(defined(errno) || defined(_MSC_VER) && defined(_INC_ERRNO))
diff --git a/bfd/wasm-module.c b/bfd/wasm-module.c
index 6806e0f81d9..3deaf42bac4 100644
--- a/bfd/wasm-module.c
+++ b/bfd/wasm-module.c
@@ -28,9 +28,7 @@
#include "sysdep.h"
#include "alloca-conf.h"
#include "bfd.h"
-#include "sysdep.h"
#include <limits.h>
-#include "bfd_stdint.h"
#include "libiberty.h"
#include "libbfd.h"
#include "wasm-module.h"
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index 880f863b4a4..8676f5f3b52 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,3 +1,13 @@
+2018-12-18 Alan Modra <amodra@gmail.com>
+
+ * arm-dis.c: Include bfd.h.
+ * aarch64-opc.c: Include bfd_stdint.h rather than stdint.h.
+ * csky-dis.c: Likewise.
+ * nds32-asm.c: Likewise.
+ * riscv-dis.c: Likewise.
+ * s12z-dis.c: Likewise.
+ * wasm32-dis.c: Likewise.
+
2018-12-07 Jim Wilson <jimw@sifive.com>
PR gas/23956
diff --git a/opcodes/aarch64-opc.c b/opcodes/aarch64-opc.c
index b047d2feab2..72ff4d5448d 100644
--- a/opcodes/aarch64-opc.c
+++ b/opcodes/aarch64-opc.c
@@ -22,7 +22,7 @@
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
-#include <stdint.h>
+#include "bfd_stdint.h"
#include <stdarg.h>
#include <inttypes.h>
diff --git a/opcodes/arm-dis.c b/opcodes/arm-dis.c
index 8e6a37b0c67..006197043d5 100644
--- a/opcodes/arm-dis.c
+++ b/opcodes/arm-dis.c
@@ -32,6 +32,7 @@
/* FIXME: This shouldn't be done here. */
#include "coff/internal.h"
#include "libcoff.h"
+#include "bfd.h"
#include "elf-bfd.h"
#include "elf/internal.h"
#include "elf/arm.h"
diff --git a/opcodes/csky-dis.c b/opcodes/csky-dis.c
index 9c3495f82dc..f57b9da6bdb 100644
--- a/opcodes/csky-dis.c
+++ b/opcodes/csky-dis.c
@@ -22,7 +22,7 @@
#include "sysdep.h"
#include "config.h"
#include <stdio.h>
-#include <stdint.h>
+#include "bfd_stdint.h"
#include "disassemble.h"
#include "elf-bfd.h"
#include "opcode/csky.h"
diff --git a/opcodes/nds32-asm.c b/opcodes/nds32-asm.c
index f0dd3266f95..94f0af20081 100644
--- a/opcodes/nds32-asm.c
+++ b/opcodes/nds32-asm.c
@@ -22,7 +22,7 @@
#include "sysdep.h"
-#include <stdint.h>
+#include "bfd_stdint.h"
#include <assert.h>
#include "safe-ctype.h"
diff --git a/opcodes/riscv-dis.c b/opcodes/riscv-dis.c
index f1bbfdb1f14..ab7575a22b2 100644
--- a/opcodes/riscv-dis.c
+++ b/opcodes/riscv-dis.c
@@ -28,7 +28,7 @@
#include "elf-bfd.h"
#include "elf/riscv.h"
-#include <stdint.h>
+#include "bfd_stdint.h"
#include <ctype.h>
struct riscv_private_data
diff --git a/opcodes/s12z-dis.c b/opcodes/s12z-dis.c
index 719f172bcc3..5d9307bb77d 100644
--- a/opcodes/s12z-dis.c
+++ b/opcodes/s12z-dis.c
@@ -20,7 +20,7 @@
#include "sysdep.h"
#include <stdio.h>
-#include <stdint.h>
+#include "bfd_stdint.h"
#include <stdbool.h>
#include <assert.h>
diff --git a/opcodes/wasm32-dis.c b/opcodes/wasm32-dis.c
index d6f16975424..9b5dea4a490 100644
--- a/opcodes/wasm32-dis.c
+++ b/opcodes/wasm32-dis.c
@@ -27,7 +27,7 @@
#include "elf-bfd.h"
#include "elf/internal.h"
#include "elf/wasm32.h"
-#include <stdint.h>
+#include "bfd_stdint.h"
/* Type names for blocks and signatures. */
#define BLOCK_TYPE_NONE 0x40