From patchwork Tue Feb 10 12:05:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 5019 Received: (qmail 10818 invoked by alias); 10 Feb 2015 12:05:11 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 10799 invoked by uid 89); 10 Feb 2015 12:05:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.2 required=5.0 tests=AWL, BAYES_00, KAM_STOCKGEN, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Tue, 10 Feb 2015 12:05:08 +0000 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t1AC56qI029755 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 10 Feb 2015 07:05:06 -0500 Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t1AC54AJ024298; Tue, 10 Feb 2015 07:05:04 -0500 Message-ID: <54D9F3EF.5070204@redhat.com> Date: Tue, 10 Feb 2015 12:05:03 +0000 From: Pedro Alves User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: Andrew Pinski CC: "gdb-patches@sourceware.org" , Binutils Development Subject: [PATCH v2] Wrap BFD headers in extern "C" References: <1423524046-20605-1-git-send-email-palves@redhat.com> <1423524046-20605-9-git-send-email-palves@redhat.com> In-Reply-To: On 02/09/2015 11:33 PM, Andrew Pinski wrote: >> --- a/bfd/elf-bfd.h >> +++ b/bfd/elf-bfd.h >> @@ -22,6 +22,10 @@ >> #ifndef _LIBELF_H_ >> #define _LIBELF_H_ 1 >> >> +#ifdef __cplusplus >> +extern "C" { >> +#endif >> + >> #include "elf/common.h" >> #include "elf/external.h" >> #include "elf/internal.h" > > This is bad form to wrap header files also. Thanks. I admit I was a bit lazy here. Here's a better patch. The posted version of the GDB series didn't link with --enable-targets=all yet (more extern "C" issues), but with this one, along with a similar opcodes patch, it will. OK to apply? --------------- From: Pedro Alves Subject: [PATCH] Wrap BFD headers in extern "C" These were the BFD changes needed for building a C++ GDB with --enable-targets=all, on x86_64 Fedora 20. For libbfd.h and libcoff.h, this does same as already done when generating bfd.h: open extern "C" in the -in.h header, and close it from the Makefile. bfd/doc/ChangeLog: 2015-02-10 Pedro Alves * Makefile.am (libbfd.h, libcoff.h): Close extern "C" scope. * Makefile.in: Regenerate. bfd/ChangeLog: 2015-02-10 Pedro Alves * libbfd-in.h [__cplusplus]: Open extern "C" scope. * libcoff-in.h [__cplusplus]: Open extern "C" scope. * libbfd.h: Regenerate. * libcoff.h: Regenerate. * elf-bfd.h [__cplusplus]: Wrap in extern "C". * mach-o.h [__cplusplus]: Wrap in extern "C". * som.h [__cplusplus]: Wrap in extern "C". --- bfd/doc/Makefile.am | 6 ++++++ bfd/doc/Makefile.in | 6 ++++++ bfd/elf-bfd.h | 7 +++++++ bfd/libbfd-in.h | 4 ++++ bfd/libbfd.h | 7 +++++++ bfd/libcoff-in.h | 4 ++++ bfd/libcoff.h | 7 +++++++ bfd/mach-o.h | 8 ++++++++ bfd/som.h | 7 +++++++ 9 files changed, 56 insertions(+) diff --git a/bfd/doc/Makefile.am b/bfd/doc/Makefile.am index 779f361..52da14e 100644 --- a/bfd/doc/Makefile.am +++ b/bfd/doc/Makefile.am @@ -275,6 +275,9 @@ libbfd.h: $(LIBBFD_H_DEP) ./$(MKDOC) -i -f $(srcdir)/proto.str < $$file >> $@ ;; \ esac; \ done + echo "#ifdef __cplusplus" >> $@ + echo "}" >> $@ + echo "#endif" >> $@ LIBCOFF_H_DEP = \ $(srcdir)/../libcoff-in.h \ @@ -294,6 +297,9 @@ libcoff.h: $(LIBCOFF_H_DEP) ./$(MKDOC) -i -f $(srcdir)/proto.str < $$file >> $@ ;; \ esac; \ done + echo "#ifdef __cplusplus" >> $@ + echo "}" >> $@ + echo "#endif" >> $@ BFD_H_DEP = \ $(srcdir)/../bfd-in.h \ diff --git a/bfd/doc/Makefile.in b/bfd/doc/Makefile.in index 78d8ec0..72099f1 100644 --- a/bfd/doc/Makefile.in +++ b/bfd/doc/Makefile.in @@ -960,6 +960,9 @@ libbfd.h: $(LIBBFD_H_DEP) ./$(MKDOC) -i -f $(srcdir)/proto.str < $$file >> $@ ;; \ esac; \ done + echo "#ifdef __cplusplus" >> $@ + echo "}" >> $@ + echo "#endif" >> $@ libcoff.h: $(LIBCOFF_H_DEP) echo "$(LIBCOFF_H_DEP)" | sed -f $(srcdir)/header.sed > $@ @@ -972,6 +975,9 @@ libcoff.h: $(LIBCOFF_H_DEP) ./$(MKDOC) -i -f $(srcdir)/proto.str < $$file >> $@ ;; \ esac; \ done + echo "#ifdef __cplusplus" >> $@ + echo "}" >> $@ + echo "#endif" >> $@ bfd.h: $(BFD_H_DEP) echo "$(BFD_H_DEP)" | sed -f $(srcdir)/header.sed > $@ diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index 49ffe79..495053d 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -27,6 +27,10 @@ #include "elf/internal.h" #include "bfdlink.h" +#ifdef __cplusplus +extern "C" { +#endif + /* The number of entries in a section is its size divided by the size of a single entry. This is normally only applicable to reloc and symbol table sections. @@ -2540,4 +2544,7 @@ extern asection _bfd_elf_large_com_section; (!(H)->unique_global \ && ((INFO)->symbolic || ((INFO)->dynamic && !(H)->dynamic))) +#ifdef __cplusplus +} +#endif #endif /* _LIBELF_H_ */ diff --git a/bfd/libbfd-in.h b/bfd/libbfd-in.h index cb7805f..7c661e3 100644 --- a/bfd/libbfd-in.h +++ b/bfd/libbfd-in.h @@ -24,6 +24,10 @@ #include "hashtab.h" +#ifdef __cplusplus +extern "C" { +#endif + /* Align an address upward to a boundary, expressed as a number of bytes. E.g. align to an 8-byte boundary with argument of 8. Take care never to wrap around if the address is within boundary-1 of the end of the diff --git a/bfd/libbfd.h b/bfd/libbfd.h index a1c0a01..bd56afb 100644 --- a/bfd/libbfd.h +++ b/bfd/libbfd.h @@ -29,6 +29,10 @@ #include "hashtab.h" +#ifdef __cplusplus +extern "C" { +#endif + /* Align an address upward to a boundary, expressed as a number of bytes. E.g. align to an 8-byte boundary with argument of 8. Take care never to wrap around if the address is within boundary-1 of the end of the @@ -3015,3 +3019,6 @@ void *bfd_arch_default_fill (bfd_size_type count, bfd_boolean code); /* Extracted from elf.c. */ +#ifdef __cplusplus +} +#endif diff --git a/bfd/libcoff-in.h b/bfd/libcoff-in.h index 6d00db0..34e71a8 100644 --- a/bfd/libcoff-in.h +++ b/bfd/libcoff-in.h @@ -22,6 +22,10 @@ #include "bfdlink.h" #include "coff-bfd.h" +#ifdef __cplusplus +extern "C" { +#endif + /* Object file tdata; access macros. */ #define coff_data(bfd) ((bfd)->tdata.coff_obj_data) diff --git a/bfd/libcoff.h b/bfd/libcoff.h index df0e00f..ee72de3 100644 --- a/bfd/libcoff.h +++ b/bfd/libcoff.h @@ -26,6 +26,10 @@ #include "bfdlink.h" #include "coff-bfd.h" +#ifdef __cplusplus +extern "C" { +#endif + /* Object file tdata; access macros. */ #define coff_data(bfd) ((bfd)->tdata.coff_obj_data) @@ -951,3 +955,6 @@ typedef struct PE object file. */ #define bfd_pei_p(abfd) \ (CONST_STRNEQ ((abfd)->xvec->name, "pei-")) +#ifdef __cplusplus +} +#endif diff --git a/bfd/mach-o.h b/bfd/mach-o.h index bc694ba..0445398 100644 --- a/bfd/mach-o.h +++ b/bfd/mach-o.h @@ -24,6 +24,10 @@ #include "bfd.h" #include "mach-o/loader.h" +#ifdef __cplusplus +extern "C" { +#endif + typedef struct bfd_mach_o_header { unsigned long magic; @@ -746,4 +750,8 @@ bfd_mach_o_backend_data; #define SYM_MACHO_FIELDS_UNSET ((bfd_vma) -1) #define SYM_MACHO_FIELDS_NOT_VALIDATED ((bfd_vma) -2) +#ifdef __cplusplus +} +#endif + #endif /* _BFD_MACH_O_H_ */ diff --git a/bfd/som.h b/bfd/som.h index a300104..7f8a5ba 100644 --- a/bfd/som.h +++ b/bfd/som.h @@ -40,6 +40,10 @@ #include #endif +#ifdef __cplusplus +extern "C" { +#endif + #if defined (HOST_HPPABSD) || defined (HOST_HPPAOSF) /* BSD uses a completely different scheme for object file identification. so for now, define _PA_RISC_ID to accept any random value for a model @@ -235,4 +239,7 @@ int ** hppa_som_gen_reloc_type (bfd *, int, int, enum hppa_reloc bfd_boolean bfd_som_attach_compilation_unit (bfd *, const char *, const char *, const char *, const char *); asection * bfd_section_from_som_symbol (bfd *abfd, struct som_external_symbol_dictionary_record *symbol); +#ifdef __cplusplus +} +#endif #endif /* _SOM_H */