]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
libelf: gelf_newehdr and gelf_newehdr should return void *.
authorAkihiko Odaki <akihiko.odaki.4i@stu.hosei.ac.jp>
Tue, 11 Oct 2016 14:12:11 +0000 (23:12 +0900)
committerMark Wielaard <mjw@redhat.com>
Wed, 7 Dec 2016 14:19:08 +0000 (15:19 +0100)
unsigned long int is not always capable to have pointer in some cases
(LLP64, for example). Return a void pointer instead. Other libelf
implementations will also make this change (or already have).
Also update the documentation to state what is created and that NULL
is returned on error (don't document that the returned value is a
pointer to the actual header created).

Signed-off-by: Akihiko Odaki <akihiko.odaki.4i@stu.hosei.ac.jp>
Signed-off-by: Mark Wielaard <mjw@redhat.com>
libelf/ChangeLog
libelf/gelf.h
libelf/gelf_newehdr.c
libelf/gelf_newphdr.c

index 6414128876c5eba443eeb2653333bc982b5c0ce8..8539cb56f975a7a438f0a48c2829870e1d6056b7 100644 (file)
@@ -1,3 +1,11 @@
+2016-10-11  Akihiko Odaki  <akihiko.odaki.4i@stu.hosei.ac.jp>
+           Mark Wielaard  <mjw@redhat.com>
+
+       * gelf.h (gelf_newehdr): Change return type to void *.
+       (gelf_newphdr): Likewise.
+       * gelf_newehdr.c (gelf_newehdr): Likewise.
+       * gelf_newphdr.c (gelf_newphdr): Likewise.
+
 2016-10-21  Mark Wielaard  <mjw@redhat.com>
 
        * elf_getdata.c (__libelf_set_rawdata_wrlock): Sanity check
index 1bc7ee72f0c709703bdf6cf35b863ea4a2332e1b..061988037784d01265ff4a2eb67efb1f31a13f6e 100644 (file)
@@ -165,8 +165,10 @@ extern GElf_Ehdr *gelf_getehdr (Elf *__elf, GElf_Ehdr *__dest);
 /* Update the ELF header.  */
 extern int gelf_update_ehdr (Elf *__elf, GElf_Ehdr *__src);
 
-/* Create new ELF header if none exists.  */
-extern unsigned long int gelf_newehdr (Elf *__elf, int __class);
+/* Create new ELF header if none exists.  Creates an Elf32_Ehdr if CLASS
+   is ELFCLASS32 or an Elf64_Ehdr if CLASS is ELFCLASS64.  Returns NULL
+   on error.  */
+extern void *gelf_newehdr (Elf *__elf, int __class);
 
 /* Get section at OFFSET.  */
 extern Elf_Scn *gelf_offscn (Elf *__elf, GElf_Off __offset);
@@ -183,8 +185,10 @@ extern GElf_Phdr *gelf_getphdr (Elf *__elf, int __ndx, GElf_Phdr *__dst);
 /* Update the program header.  */
 extern int gelf_update_phdr (Elf *__elf, int __ndx, GElf_Phdr *__src);
 
-/* Create new program header with PHNUM entries.  */
-extern unsigned long int gelf_newphdr (Elf *__elf, size_t __phnum);
+/* Create new program header with PHNUM entries.  Creates either an
+   Elf32_Phdr or an Elf64_Phdr depending on whether the given ELF is
+   ELFCLASS32 or ELFCLASS64.  Returns NULL on error.  */
+extern void *gelf_newphdr (Elf *__elf, size_t __phnum);
 
 /* Get compression header of section if any.  Returns NULL and sets
    elf_errno if the section isn't compressed or an error occurred.  */
index cfa80e1bd35a6200be9bbaa32fca96a2ab623432..2788906605a3c520f469c1ceb6aed4dc7b9af4c3 100644 (file)
 #include "libelfP.h"
 
 
-unsigned long int
+void *
 gelf_newehdr (Elf *elf, int class)
 {
   return (class == ELFCLASS32
-         ? (unsigned long int) INTUSE(elf32_newehdr) (elf)
-         : (unsigned long int) INTUSE(elf64_newehdr) (elf));
+         ? (void *) INTUSE(elf32_newehdr) (elf)
+         : (void *) INTUSE(elf64_newehdr) (elf));
 }
index 4e95474e20ae8084e8b460b4170be0ee5e2492c5..84aad781f5414521b15869c19d5bc3009112ec66 100644 (file)
 #include "libelfP.h"
 
 
-unsigned long int
+void *
 gelf_newphdr ( Elf *elf, size_t phnum)
 {
   return (elf->class == ELFCLASS32
-         ? (unsigned long int) INTUSE(elf32_newphdr) (elf, phnum)
-         : (unsigned long int) INTUSE(elf64_newphdr) (elf, phnum));
+         ? (void *) INTUSE(elf32_newphdr) (elf, phnum)
+         : (void *) INTUSE(elf64_newphdr) (elf, phnum));
 }