]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Make __attribute__ conditional in all installed headers
authorUlf Hermann <ulf.hermann@qt.io>
Thu, 20 Apr 2017 13:55:47 +0000 (15:55 +0200)
committerMark Wielaard <mark@klomp.org>
Tue, 2 May 2017 11:07:28 +0000 (13:07 +0200)
__attribute__ is a GNU extension. If we want to link against the
libraries using a different compiler, it needs to be disabled. It was
already disabled in libdw.h, and this patch extends this to the other
headers. We move the defines to libelf.h as that is included in all
the others.

Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
libdw/ChangeLog
libdw/libdw.h
libdwfl/ChangeLog
libdwfl/libdwfl.h
libebl/ChangeLog
libebl/libebl.h
libelf/ChangeLog
libelf/libelf.h

index 19bcc9bb178be67c9cd80af0c5bf710a7cc6ab83..1e282e4e3efb9cb6e56994519abe0370fb224def 100644 (file)
@@ -1,3 +1,8 @@
+2017-04-20  Ulf Hermann  <ulf.hermann@qt.io>
+
+       * libdw.h: Remove attribute macro declarations and use
+       __noreturn_attribute__ as defined in libelf.h.
+
 2017-04-20  Ulf Hermann  <ulf.hermann@qt.io>
 
        * dwarf_begin_elf.c: Include endian.h.
index 473e1a25804aecbe6f81cd79039d33ba4271b035..9ae80ebb3880a421d84497b6d813d6dec4e604e6 100644 (file)
 #include <stddef.h>
 #include <stdint.h>
 
-
-#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
-# define __nonnull_attribute__(...) __attribute__ ((__nonnull__ (__VA_ARGS__)))
-# define __deprecated_attribute__ __attribute__ ((__deprecated__))
-#else
-# define __nonnull_attribute__(args...)
-# define __deprecated_attribute__
-#endif
-
-
-#ifdef __GNUC_STDC_INLINE__
-# define __libdw_extern_inline extern __inline __attribute__ ((__gnu_inline__))
-#else
-# define __libdw_extern_inline extern __inline
-#endif
-
-
 /* Mode for the session.  */
 typedef enum
   {
@@ -242,11 +225,7 @@ typedef struct Dwarf Dwarf;
 
 
 /* Out-Of-Memory handler.  */
-#if __GNUC__ < 4
-typedef void (*Dwarf_OOM) (void);
-#else
-typedef void (*__attribute__ ((noreturn)) Dwarf_OOM) (void);
-#endif
+typedef void (*__noreturn_attribute__ Dwarf_OOM) (void);
 
 
 #ifdef __cplusplus
index 9de28778a26baed983619d1992275d36ebafbdbf..b9be1bce19f2d0f932cfa484c04e3d99528450f6 100644 (file)
@@ -1,3 +1,7 @@
+2017-04-20  Ulf Hermann  <ulf.hermann@qt.io>
+
+       * libdwfl.h: Use __const_attribute__.
+
 2017-04-20  Ulf Hermann  <ulf.hermann@qt.io>
 
        * elf-from-memory.c: Explicitly cast phnum to size_t.
index aea8b993124a040d9e4b837e75d8cd517c581e33..a0c1d35735c4ce64c5b41b5d91d812a5550f110c 100644 (file)
@@ -385,7 +385,7 @@ extern int dwfl_linux_proc_find_elf (Dwfl_Module *mod, void **userdata,
 
 /* Standard argument parsing for using a standard callback set.  */
 struct argp;
-extern const struct argp *dwfl_standard_argp (void) __attribute__ ((const));
+extern const struct argp *dwfl_standard_argp (void) __const_attribute__;
 
 
 /*** Relocation of addresses from Dwfl ***/
index 719d08d0232ce3373cb4e4382318bbbbe5bd500b..506915bade1934d679f797a8a39185bd86674ec4 100644 (file)
@@ -1,3 +1,7 @@
+2017-04-20  Ulf Hermann  <ulf.hermann@qt.io>
+
+       * libebl.h: Use __pure_attribute__.
+
 2017-02-15  Ulf Hermann  <ulf.hermann@qt.io>
 
        * eblmachineflagname.c: Include system.h.
index c8e01fe9b64fb02e2cbd201336000c60a3220392..87896e4acbd26ac4425796e29992f98abc5cc75f 100644 (file)
@@ -73,13 +73,13 @@ extern void ebl_closebackend (Ebl *bh);
 /* Information about the descriptor.  */
 
 /* Get ELF machine.  */
-extern int ebl_get_elfmachine (Ebl *ebl) __attribute__ ((__pure__));
+extern int ebl_get_elfmachine (Ebl *ebl) __pure_attribute__;
 
 /* Get ELF class.  */
-extern int ebl_get_elfclass (Ebl *ebl) __attribute__ ((__pure__));
+extern int ebl_get_elfclass (Ebl *ebl) __pure_attribute__;
 
 /* Get ELF data encoding.  */
-extern int ebl_get_elfdata (Ebl *ebl) __attribute__ ((__pure__));
+extern int ebl_get_elfdata (Ebl *ebl) __pure_attribute__;
 
 
 /* Function to call the callback functions including default ELF
index 4f232289affe8263d35bdec0c67476baf23942b0..dd82a43319fd56a7727d4f63b577730f5d794055 100644 (file)
@@ -1,3 +1,8 @@
+2017-04-20  Ulf Hermann  <ulf.hermann@qt.io>
+
+       * libelf.h: Define macros for various function attributes and use
+       them.
+
 2017-04-20  Ulf Hermann  <ulf.hermann@qt.io>
 
        * elf_update.c: Set ELF_F_MMAPPED flag if we mmap from elf_update.
index c0d6389f3856fda95a7796d6618a8fdae8f7bd64..547c0f5081d2a60a12ad55ee7e55fd07cfd209fb 100644 (file)
  #define ELFCOMPRESS_HIPROC     0x7fffffff /* End of processor-specific.  */
 #endif
 
+#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
+# define __nonnull_attribute__(...) __attribute__ ((__nonnull__ (__VA_ARGS__)))
+# define __deprecated_attribute__ __attribute__ ((__deprecated__))
+# define __pure_attribute__ __attribute__ ((__pure__))
+# define __const_attribute__ __attribute__ ((__const__))
+#else
+# define __nonnull_attribute__(...)
+# define __deprecated_attribute__
+# define __pure_attribute__
+# define __const_attribute__
+#endif
+
+#if __GNUC__ < 4
+#define __noreturn_attribute__
+#else
+#define __noreturn_attribute__ __attribute__ ((noreturn))
+#endif
+
+#ifdef __GNUC_STDC_INLINE__
+# define __libdw_extern_inline extern __inline __attribute__ ((__gnu_inline__))
+#else
+# define __libdw_extern_inline extern __inline
+#endif
+
 /* Known translation types.  */
 typedef enum
 {
@@ -216,7 +240,7 @@ extern int elf_end (Elf *__elf);
 extern int64_t elf_update (Elf *__elf, Elf_Cmd __cmd);
 
 /* Determine what kind of file is associated with ELF.  */
-extern Elf_Kind elf_kind (Elf *__elf) __attribute__ ((__pure__));
+extern Elf_Kind elf_kind (Elf *__elf) __pure_attribute__;
 
 /* Get the base offset for an object file.  */
 extern int64_t elf_getbase (Elf *__elf);
@@ -282,7 +306,7 @@ extern int elf_getshdrnum (Elf *__elf, size_t *__dst);
    It was agreed to make the same functionality available under a different
    name and obsolete the old name.  */
 extern int elf_getshnum (Elf *__elf, size_t *__dst)
-     __attribute__ ((__deprecated__));
+     __deprecated_attribute__;
 
 
 /* Get the section index of the section header string table in the ELF
@@ -294,7 +318,7 @@ extern int elf_getshdrstrndx (Elf *__elf, size_t *__dst);
    It was agreed to make the same functionality available under a different
    name and obsolete the old name.  */
 extern int elf_getshstrndx (Elf *__elf, size_t *__dst)
-     __attribute__ ((__deprecated__));
+     __deprecated_attribute__;
 
 
 /* Retrieve section header of ELFCLASS32 binary.  */
@@ -429,11 +453,11 @@ extern char *elf_rawfile (Elf *__elf, size_t *__nbytes);
    The result is based on version VERSION of the ELF standard.  */
 extern size_t elf32_fsize (Elf_Type __type, size_t __count,
                           unsigned int __version)
-       __attribute__ ((__const__));
+       __const_attribute__;
 /* Similar but this time the binary calls is ELFCLASS64.  */
 extern size_t elf64_fsize (Elf_Type __type, size_t __count,
                           unsigned int __version)
-       __attribute__ ((__const__));
+       __const_attribute__;
 
 
 /* Convert data structure from the representation in the file represented
@@ -472,11 +496,11 @@ extern void elf_fill (int __fill);
 
 /* Compute hash value.  */
 extern unsigned long int elf_hash (const char *__string)
-       __attribute__ ((__pure__));
+       __pure_attribute__;
 
 /* Compute hash value using the GNU-specific hash function.  */
 extern unsigned long int elf_gnu_hash (const char *__string)
-       __attribute__ ((__pure__));
+       __pure_attribute__;
 
 
 /* Compute simple checksum from permanent parts of the ELF file.  */