From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 43AAF138334 for ; Thu, 7 Jun 2018 14:09:48 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D4DACE0B09; Thu, 7 Jun 2018 14:09:46 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 78D9DE0AFC for ; Thu, 7 Jun 2018 14:09:46 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 884FC335CA8 for ; Thu, 7 Jun 2018 14:09:44 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 5B7932CD for ; Thu, 7 Jun 2018 14:09:41 +0000 (UTC) From: "Mike Frysinger" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Frysinger" Message-ID: <1528380350.a109e4867c86638c2c7612e20fe37e5aafc139bc.vapier@gentoo> Subject: [gentoo-commits] proj/pax-utils:master commit in: / X-VCS-Repository: proj/pax-utils X-VCS-Files: scanelf.c X-VCS-Directories: / X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: a109e4867c86638c2c7612e20fe37e5aafc139bc X-VCS-Branch: master Date: Thu, 7 Jun 2018 14:09:41 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 9f439758-e863-427f-bf9c-01e8e145d360 X-Archives-Hash: bea56f20ea1455c727af13c7fb62ecf8 commit: a109e4867c86638c2c7612e20fe37e5aafc139bc Author: Mike Frysinger gentoo org> AuthorDate: Sat Mar 4 20:36:07 2017 +0000 Commit: Mike Frysinger gentoo org> CommitDate: Thu Jun 7 14:05:50 2018 +0000 URL: https://gitweb.gentoo.org/proj/pax-utils.git/commit/?id=a109e486 scanelf: add general const markings to Elf pointers scanelf.c | 72 +++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/scanelf.c b/scanelf.c index 6dcc51e..7936e3c 100644 --- a/scanelf.c +++ b/scanelf.c @@ -150,8 +150,8 @@ static ssize_t scanelf_file_find_phdr(elfobj *elf, uint32_t p_type) #define FIND_PT_TYPE(B) \ size_t i; \ - Elf##B##_Ehdr *ehdr = EHDR ## B (elf->ehdr); \ - Elf##B##_Phdr *phdr = PHDR ## B (elf->phdr); \ + const Elf##B##_Ehdr *ehdr = EHDR ## B (elf->ehdr); \ + const Elf##B##_Phdr *phdr = PHDR ## B (elf->phdr); \ \ for (i = 0; i < EGET(ehdr->e_phnum); i++) { \ if (EGET(phdr[i].p_type) != p_type) \ @@ -168,14 +168,14 @@ static ssize_t scanelf_file_find_phdr(elfobj *elf, uint32_t p_type) return ret; } -static void *scanelf_file_get_pt_dynamic(elfobj *elf) +static const void *scanelf_file_get_pt_dynamic(elfobj *elf) { ssize_t i = scanelf_file_find_phdr(elf, PT_DYNAMIC); if (i == -1) return NULL; #define CHECK_PT_DYNAMIC(B) \ - Elf##B##_Phdr *phdr = &PHDR##B(elf->phdr)[i]; \ + const Elf##B##_Phdr *phdr = &PHDR##B(elf->phdr)[i]; \ Elf##B##_Off offset; \ \ if (EGET(phdr->p_filesz) == 0) \ @@ -191,7 +191,7 @@ static void *scanelf_file_get_pt_dynamic(elfobj *elf) #define scanelf_dt_for_each(B, elf, dyn) \ { \ - Elf##B##_Phdr *_phdr = scanelf_file_get_pt_dynamic(elf); \ + const Elf##B##_Phdr *_phdr = scanelf_file_get_pt_dynamic(elf); \ dyn = (_phdr == NULL) ? elf->data_end : DYN##B(elf->vdata + EGET(_phdr->p_offset)); \ } \ --dyn; \ @@ -337,14 +337,14 @@ static void scanelf_file_get_symtabs(elfobj *elf, const void **sym, const void * } \ \ if (vsym >= vaddr && vsym < vaddr + filesz) { \ - Elf##B##_Shdr *shdr = &sym_shdr; \ + const Elf##B##_Shdr *shdr = &sym_shdr; \ ESET(sym_shdr.sh_offset, offset + (vsym - vaddr)); \ if (VALID_SHDR(elf, shdr)) \ *sym = shdr; \ } \ \ if (vstr >= vaddr && vstr < vaddr + filesz) { \ - Elf##B##_Shdr *shdr = &str_shdr; \ + const Elf##B##_Shdr *shdr = &str_shdr; \ ESET(str_shdr.sh_offset, offset + (vstr - vaddr)); \ if (VALID_SHDR(elf, shdr)) \ *str = shdr; \ @@ -369,7 +369,7 @@ static const char *scanelf_file_pax(elfobj *elf, char *found_pax) memset(&ret, 0, sizeof(ret)); #define SHOW_PAX(B) \ - Elf ## B ## _Ehdr *ehdr = EHDR ## B (elf->ehdr); \ + const Elf ## B ## _Ehdr *ehdr = EHDR ## B (elf->ehdr); \ Elf ## B ## _Phdr *phdr = PHDR ## B (elf->phdr); \ for (i = 0; i < EGET(ehdr->e_phnum); i++) { \ if (EGET(phdr[i].p_type) != PT_PAX_FLAGS) \ @@ -426,7 +426,7 @@ static const char *scanelf_file_phdr(elfobj *elf, char *found_phdr, char *found_ #define NOTE_GNU_STACK ".note.GNU-stack" #define SHOW_PHDR(B) \ - Elf ## B ## _Ehdr *ehdr = EHDR ## B (elf->ehdr); \ + const Elf ## B ## _Ehdr *ehdr = EHDR ## B (elf->ehdr); \ Elf ## B ## _Off offset; \ uint32_t flags, check_flags; \ if (elf->phdr != NULL) { \ @@ -468,9 +468,9 @@ static const char *scanelf_file_phdr(elfobj *elf, char *found_phdr, char *found_ } \ } else if (elf->shdr != NULL) { \ /* no program headers which means this is prob an object file */ \ - Elf ## B ## _Shdr *shdr = SHDR ## B (elf->shdr); \ + const Elf ## B ## _Shdr *shdr = SHDR ## B (elf->shdr); \ uint16_t shstrndx = EGET(ehdr->e_shstrndx); \ - Elf ## B ## _Shdr *strtbl = shdr + shstrndx; \ + const Elf ## B ## _Shdr *strtbl = shdr + shstrndx; \ uint16_t shnum = EGET(ehdr->e_shnum); \ if (shstrndx >= shnum || !VALID_SHDR(elf, strtbl)) \ goto corrupt_shdr; \ @@ -533,7 +533,7 @@ static const char *scanelf_file_textrel(elfobj *elf, char *found_textrel) if (file_matches_list(elf->filename, qa_textrels)) return NULL; #define SHOW_TEXTREL(B) \ - Elf ## B ## _Dyn *dyn; \ + const Elf ## B ## _Dyn *dyn; \ \ scanelf_dt_for_each(B, elf, dyn) { \ if (EGET(dyn->d_tag) == DT_TEXTREL) { /*dyn->d_tag != DT_FLAGS)*/ \ @@ -571,13 +571,13 @@ static const char *scanelf_file_textrels(elfobj *elf, char *found_textrels, char #define SHOW_TEXTRELS(B) \ size_t i; \ - Elf ## B ## _Ehdr *ehdr = EHDR ## B (elf->ehdr); \ - Elf ## B ## _Phdr *phdr; \ - Elf ## B ## _Shdr *symtab = SHDR ## B (symtab_void); \ - Elf ## B ## _Shdr *strtab = SHDR ## B (strtab_void); \ - Elf ## B ## _Rel *rel; \ - Elf ## B ## _Rela *rela; \ - Elf ## B ## _Dyn *dyn, *drel, *drelsz, *drelent, *dpltrel; \ + const Elf ## B ## _Ehdr *ehdr = EHDR ## B (elf->ehdr); \ + const Elf ## B ## _Phdr *phdr; \ + const Elf ## B ## _Shdr *symtab = SHDR ## B (symtab_void); \ + const Elf ## B ## _Shdr *strtab = SHDR ## B (strtab_void); \ + const Elf ## B ## _Rel *rel; \ + const Elf ## B ## _Rela *rela; \ + const Elf ## B ## _Dyn *dyn, *drel, *drelsz, *drelent, *dpltrel; \ uint32_t pltrel; \ Elf ## B ## _Addr load_address = 0; \ Elf ## B ## _Addr file_offset; \ @@ -669,8 +669,8 @@ static const char *scanelf_file_textrels(elfobj *elf, char *found_textrels, char for (r = 0; r < rmax; ++r) { \ unsigned long sym_max; \ Elf ## B ## _Addr offset_tmp; \ - Elf ## B ## _Sym *func; \ - Elf ## B ## _Sym *sym; \ + const Elf ## B ## _Sym *func; \ + const Elf ## B ## _Sym *sym; \ Elf ## B ## _Addr r_offset; \ uint ## B ## _t r_info; \ if (pltrel == DT_REL) { \ @@ -805,7 +805,7 @@ static void scanelf_file_rpath(elfobj *elf, char *found_rpath, char **ret, size_ #define SHOW_RPATH(B) \ Elf ## B ## _Dyn *dyn; \ - Elf ## B ## _Shdr *strtab = SHDR ## B (strtab_void); \ + const Elf ## B ## _Shdr *strtab = SHDR ## B (strtab_void); \ Elf ## B ## _Off offset; \ Elf ## B ## _Xword word; \ \ @@ -960,8 +960,8 @@ static const char *scanelf_file_needed_lib(elfobj *elf, char *found_needed, char strtab_void = elf_findsecbyname(elf, ".dynstr"); #define SHOW_NEEDED(B) \ - Elf ## B ## _Dyn *dyn; \ - Elf ## B ## _Shdr *strtab = SHDR ## B (strtab_void); \ + const Elf ## B ## _Dyn *dyn; \ + const Elf ## B ## _Shdr *strtab = SHDR ## B (strtab_void); \ size_t matched = 0; \ \ /* Walk all the dynamic tags to find NEEDED entries */ \ @@ -1023,8 +1023,8 @@ static const char *scanelf_file_interp(elfobj *elf, char *found_interp) /* Walk all the program headers to find the PT_INTERP */ #define GET_PT_INTERP(B) \ size_t i; \ - Elf ## B ## _Ehdr *ehdr = EHDR ## B (elf->ehdr); \ - Elf ## B ## _Phdr *phdr = PHDR ## B (elf->phdr); \ + const Elf ## B ## _Ehdr *ehdr = EHDR ## B (elf->ehdr); \ + const Elf ## B ## _Phdr *phdr = PHDR ## B (elf->phdr); \ for (i = 0; i < EGET(ehdr->e_phnum); ++i) { \ if (EGET(phdr[i].p_type) == PT_INTERP) { \ offset = EGET(phdr[i].p_offset); \ @@ -1037,7 +1037,7 @@ static const char *scanelf_file_interp(elfobj *elf, char *found_interp) const void *section = elf_findsecbyname(elf, ".interp"); #define GET_INTERP(B) \ - Elf ## B ## _Shdr *shdr = SHDR ## B (section); \ + const Elf ## B ## _Shdr *shdr = SHDR ## B (section); \ offset = EGET(shdr->sh_offset); if (section) SCANELF_ELF_SIZED(GET_INTERP); @@ -1066,7 +1066,7 @@ static const char *scanelf_file_bind(elfobj *elf, char *found_bind) if (!elf->phdr) return NULL; #define SHOW_BIND(B) \ - Elf ## B ## _Dyn *dyn; \ + const Elf ## B ## _Dyn *dyn; \ \ scanelf_dt_for_each(B, elf, dyn) { \ dynamic = true; \ @@ -1105,9 +1105,9 @@ static const char *scanelf_file_soname(elfobj *elf, char *found_soname) strtab_void = elf_findsecbyname(elf, ".dynstr"); #define SHOW_SONAME(B) \ - Elf ## B ## _Dyn *dyn; \ - Elf ## B ## _Ehdr *ehdr = EHDR ## B (elf->ehdr); \ - Elf ## B ## _Shdr *strtab = SHDR ## B (strtab_void); \ + const Elf ## B ## _Dyn *dyn; \ + const Elf ## B ## _Ehdr *ehdr = EHDR ## B (elf->ehdr); \ + const Elf ## B ## _Shdr *strtab = SHDR ## B (strtab_void); \ \ /* only look for soname in shared objects */ \ if (EGET(ehdr->e_type) != ET_DYN) \ @@ -1306,11 +1306,11 @@ static char *scanelf_file_sym(elfobj *elf, char *found_sym) scanelf_file_get_symtabs(elf, &symtab_void, &strtab_void); #define FIND_SYM(B) \ - Elf ## B ## _Shdr *symtab = SHDR ## B (symtab_void); \ - Elf ## B ## _Shdr *strtab = SHDR ## B (strtab_void); \ - Elf ## B ## _Sym *sym = SYM ## B (elf->vdata + EGET(symtab->sh_offset)); \ + const Elf ## B ## _Shdr *symtab = SHDR ## B (symtab_void); \ + const Elf ## B ## _Shdr *strtab = SHDR ## B (strtab_void); \ + const Elf ## B ## _Sym *sym = SYM ## B (elf->vdata + EGET(symtab->sh_offset)); \ Elf ## B ## _Word i, cnt = EGET(symtab->sh_entsize); \ - char *symname; \ + const char *symname; \ size_t ret_len = 0; \ if (cnt) \ cnt = EGET(symtab->sh_size) / cnt; \ @@ -1367,7 +1367,7 @@ static const char *scanelf_file_sections(elfobj *elf, char *found_section) size_t matched, n; \ int invert; \ const char *section_name; \ - Elf ## B ## _Shdr *section; \ + const Elf ## B ## _Shdr *section; \ \ matched = 0; \ array_for_each(find_section_arr, n, section_name) { \