* [gentoo-commits] gentoo-projects commit in pax-utils: paxelf.c paxelf.h scanelf.c
@ 2012-04-28 5:14 Mike Frysinger (vapier)
0 siblings, 0 replies; 2+ messages in thread
From: Mike Frysinger (vapier) @ 2012-04-28 5:14 UTC (permalink / raw
To: gentoo-commits
vapier 12/04/28 05:14:26
Modified: paxelf.c paxelf.h scanelf.c
Log:
drop EI_PAX setting when modifying pax flags #411919
Revision Changes Path
1.71 pax-utils/paxelf.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/paxelf.c?rev=1.71&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/paxelf.c?rev=1.71&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/paxelf.c?r1=1.70&r2=1.71
Index: paxelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/paxelf.c,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -r1.70 -r1.71
--- paxelf.c 15 Jan 2010 12:06:37 -0000 1.70
+++ paxelf.c 28 Apr 2012 05:14:26 -0000 1.71
@@ -1,7 +1,7 @@
/*
* Copyright 2003-2007 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/paxelf.c,v 1.70 2010/01/15 12:06:37 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/paxelf.c,v 1.71 2012/04/28 05:14:26 vapier Exp $
*
* Copyright 2005-2007 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2007 Mike Frysinger - <vapier@gentoo.org>
@@ -675,56 +675,6 @@
return buffer;
}
-unsigned long pax_pf2hf_flags(unsigned long paxflags)
-{
- unsigned long flags = 0;
- char *pf_flags = pax_short_pf_flags(paxflags);
- size_t x, len = strlen(pf_flags);
- for (x = 0; x < len; x++) {
- switch (pf_flags[x]) {
- case 'p':
- flags |= HF_PAX_PAGEEXEC;
- break;
- case 'P':
- flags = (flags & ~HF_PAX_PAGEEXEC) | HF_PAX_SEGMEXEC;
- break;
- case 'E':
- flags |= HF_PAX_EMUTRAMP;
- break;
- case 'e':
- flags = (flags & ~HF_PAX_EMUTRAMP);
- break;
- case 'm':
- flags |= HF_PAX_MPROTECT;
- break;
- case 'M':
- flags = (flags & ~HF_PAX_MPROTECT);
- break;
- case 'r':
- flags |= HF_PAX_RANDMMAP;
- break;
- case 'R':
- flags = (flags & ~HF_PAX_RANDMMAP);
- break;
- case 'X':
- flags |= HF_PAX_RANDEXEC;
- break;
- case 'x':
- flags = (flags & ~HF_PAX_RANDEXEC);
- break;
- case 's':
- flags |= HF_PAX_SEGMEXEC;
- break;
- case 'S':
- flags = (flags & ~HF_PAX_SEGMEXEC) | HF_PAX_PAGEEXEC;
- break;
- default:
- break;
- }
- }
- return flags;
-}
-
char *gnu_short_stack_flags(unsigned long flags)
{
static char buffer[4];
1.57 pax-utils/paxelf.h
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/paxelf.h?rev=1.57&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/paxelf.h?rev=1.57&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/paxelf.h?r1=1.56&r2=1.57
Index: paxelf.h
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/paxelf.h,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -r1.56 -r1.57
--- paxelf.h 15 Jan 2010 12:06:37 -0000 1.56
+++ paxelf.h 28 Apr 2012 05:14:26 -0000 1.57
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2007 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/paxelf.h,v 1.56 2010/01/15 12:06:37 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/paxelf.h,v 1.57 2012/04/28 05:14:26 vapier Exp $
*
* Copyright 2005-2007 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2007 Mike Frysinger - <vapier@gentoo.org>
@@ -67,7 +67,6 @@
extern int get_etype(elfobj *elf);
extern int get_emtype(elfobj *elf);
extern void print_etypes(FILE *);
-extern unsigned long pax_pf2hf_flags(unsigned long);
extern int etype_lookup(const char *);
/* PaX flags (to be read in elfhdr.e_flags) */
1.242 pax-utils/scanelf.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.242&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.242&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.241&r2=1.242
Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.241
retrieving revision 1.242
diff -u -r1.241 -r1.242
--- scanelf.c 25 Jan 2012 01:58:29 -0000 1.241
+++ scanelf.c 28 Apr 2012 05:14:26 -0000 1.242
@@ -1,13 +1,13 @@
/*
* Copyright 2003-2007 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.241 2012/01/25 01:58:29 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.242 2012/04/28 05:14:26 vapier Exp $
*
* Copyright 2003-2007 Ned Ludd - <solar@gentoo.org>
* Copyright 2004-2007 Mike Frysinger - <vapier@gentoo.org>
*/
-static const char rcsid[] = "$Id: scanelf.c,v 1.241 2012/01/25 01:58:29 vapier Exp $";
+static const char rcsid[] = "$Id: scanelf.c,v 1.242 2012/04/28 05:14:26 vapier Exp $";
const char argv0[] = "scanelf";
#include "paxinc.h"
@@ -299,16 +299,12 @@
SHOW_PAX(64)
}
- if (fix_elf && setpax) {
- /* set the chpax settings */
- if (elf->elf_class == ELFCLASS32) {
- if (EHDR32(elf->ehdr)->e_type == ET_DYN || EHDR32(elf->ehdr)->e_type == ET_EXEC)
- ESET(EHDR32(elf->ehdr)->e_ident[EI_PAX], pax_pf2hf_flags(setpax));
- } else {
- if (EHDR64(elf->ehdr)->e_type == ET_DYN || EHDR64(elf->ehdr)->e_type == ET_EXEC)
- ESET(EHDR64(elf->ehdr)->e_ident[EI_PAX], pax_pf2hf_flags(setpax));
- }
- }
+ /* Note: We do not support setting EI_PAX if not PT_PAX_FLAGS
+ * was found. This is known to break ELFs on glibc systems,
+ * and mainline PaX has deprecated use of this for a long time.
+ * We could support changing PT_GNU_STACK, but that doesn't
+ * seem like it's worth the effort. #411919
+ */
/* fall back to EI_PAX if no PT_PAX was found */
if (!*ret) {
^ permalink raw reply [flat|nested] 2+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: paxelf.c paxelf.h scanelf.c
@ 2014-06-18 3:16 Mike Frysinger (vapier)
0 siblings, 0 replies; 2+ messages in thread
From: Mike Frysinger (vapier) @ 2014-06-18 3:16 UTC (permalink / raw
To: gentoo-commits
vapier 14/06/18 03:16:52
Modified: paxelf.c paxelf.h scanelf.c
Log:
add support for symbol visibility
Revision Changes Path
1.81 pax-utils/paxelf.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/paxelf.c?rev=1.81&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/paxelf.c?rev=1.81&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/paxelf.c?r1=1.80&r2=1.81
Index: paxelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/paxelf.c,v
retrieving revision 1.80
retrieving revision 1.81
diff -u -r1.80 -r1.81
--- paxelf.c 11 Jan 2014 00:57:16 -0000 1.80
+++ paxelf.c 18 Jun 2014 03:16:52 -0000 1.81
@@ -1,7 +1,7 @@
/*
* Copyright 2003-2012 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/paxelf.c,v 1.80 2014/01/11 00:57:16 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/paxelf.c,v 1.81 2014/06/18 03:16:52 vapier Exp $
*
* Copyright 2005-2012 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2012 Mike Frysinger - <vapier@gentoo.org>
@@ -447,6 +447,19 @@
return find_pairtype(elf_stbtypes, type);
}
+/* translate elf STV_ defines */
+static pairtype elf_stvtypes[] = {
+ QUERY(STV_DEFAULT),
+ QUERY(STV_INTERNAL),
+ QUERY(STV_HIDDEN),
+ QUERY(STV_PROTECTED),
+ { 0, 0 }
+};
+const char *get_elfstvtype(int type)
+{
+ return find_pairtype(elf_stvtypes, type);
+}
+
/* translate elf SHN_ defines */
static pairtype elf_shntypes[] = {
QUERY(SHN_UNDEF),
1.60 pax-utils/paxelf.h
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/paxelf.h?rev=1.60&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/paxelf.h?rev=1.60&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/paxelf.h?r1=1.59&r2=1.60
Index: paxelf.h
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/paxelf.h,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -r1.59 -r1.60
--- paxelf.h 18 Nov 2012 07:39:45 -0000 1.59
+++ paxelf.h 18 Jun 2014 03:16:52 -0000 1.60
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2012 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/paxelf.h,v 1.59 2012/11/18 07:39:45 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/paxelf.h,v 1.60 2014/06/18 03:16:52 vapier Exp $
*
* Copyright 2005-2012 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2012 Mike Frysinger - <vapier@gentoo.org>
@@ -61,6 +61,7 @@
extern const char *get_elfshntype(int type);
extern const char *get_elfshttype(int type);
extern const char *get_elfstbtype(int type);
+extern const char *get_elfstvtype(int type);
extern const char *get_elfstttype(int type);
extern void *elf_findsecbyname(elfobj *elf, const char *name);
extern int get_etype(elfobj *elf);
1.266 pax-utils/scanelf.c
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.266&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?rev=1.266&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/scanelf.c?r1=1.265&r2=1.266
Index: scanelf.c
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v
retrieving revision 1.265
retrieving revision 1.266
diff -u -r1.265 -r1.266
--- scanelf.c 21 Mar 2014 05:33:33 -0000 1.265
+++ scanelf.c 18 Jun 2014 03:16:52 -0000 1.266
@@ -1,13 +1,13 @@
/*
* Copyright 2003-2012 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.265 2014/03/21 05:33:33 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/pax-utils/scanelf.c,v 1.266 2014/06/18 03:16:52 vapier Exp $
*
* Copyright 2003-2012 Ned Ludd - <solar@gentoo.org>
* Copyright 2004-2012 Mike Frysinger - <vapier@gentoo.org>
*/
-static const char rcsid[] = "$Id: scanelf.c,v 1.265 2014/03/21 05:33:33 vapier Exp $";
+static const char rcsid[] = "$Id: scanelf.c,v 1.266 2014/06/18 03:16:52 vapier Exp $";
const char argv0[] = "scanelf";
#include "paxinc.h"
@@ -1195,6 +1195,7 @@
* groups and their types are:
* STT group: STT_NOTYPE:n STT_OBJECT:o STT_FUNC:f STT_FILE:F
* STB group: STB_LOCAL:l STB_GLOBAL:g STB_WEAK:w
+ * STV group: STV_DEFAULT:p STV_INTERNAL:i STV_HIDDEN:h STV_PROTECTED:P
* SHN group: SHN_UNDEF:u SHN_ABS:a SHN_COMMON:c {defined}:d
* The "defined" value in the SHN group does not correspond to a SHN_xxx define.
* You can search for multiple symbols at once by seperating with a comma (",").
@@ -1213,7 +1214,7 @@
*/
static void
scanelf_match_symname(elfobj *elf, char *found_sym, char **ret, size_t *ret_len, const char *symname,
- unsigned int stt, unsigned int stb, unsigned int shn, unsigned long size)
+ unsigned int stt, unsigned int stb, unsigned int stv, unsigned int shn, unsigned long size)
{
const char *this_sym;
size_t n;
@@ -1221,12 +1222,14 @@
array_for_each(find_sym_arr, n, this_sym) {
bool inc_notype, inc_object, inc_func, inc_file,
inc_local, inc_global, inc_weak,
+ inc_visdef, inc_intern, inc_hidden, inc_prot,
inc_def, inc_undef, inc_abs, inc_common;
/* symbol selection! */
- inc_notype = inc_object = inc_func = inc_file = \
- inc_local = inc_global = inc_weak = \
- inc_def = inc_undef = inc_abs = inc_common = \
+ inc_notype = inc_object = inc_func = inc_file =
+ inc_local = inc_global = inc_weak =
+ inc_visdef = inc_intern = inc_hidden = inc_prot =
+ inc_def = inc_undef = inc_abs = inc_common =
(*this_sym != '%');
/* parse the contents of %...% */
@@ -1244,6 +1247,10 @@
case 'l': inc_local = true; break;
case 'g': inc_global = true; break;
case 'w': inc_weak = true; break;
+ case 'p': inc_visdef = true; break;
+ case 'i': inc_intern = true; break;
+ case 'h': inc_hidden = true; break;
+ case 'P': inc_prot = true; break;
case 'd': inc_def = true; break;
case 'u': inc_undef = true; break;
case 'a': inc_abs = true; break;
@@ -1257,6 +1264,8 @@
inc_notype = inc_object = inc_func = inc_file = true;
if (!inc_local && !inc_global && !inc_weak)
inc_local = inc_global = inc_weak = true;
+ if (!inc_visdef && !inc_intern && !inc_hidden && !inc_prot)
+ inc_visdef = inc_intern = inc_hidden = inc_prot = true;
if (!inc_def && !inc_undef && !inc_abs && !inc_common)
inc_def = inc_undef = inc_abs = inc_common = true;
@@ -1270,27 +1279,32 @@
}
/* filter symbols */
- if ((!inc_notype && stt == STT_NOTYPE) || \
- (!inc_object && stt == STT_OBJECT) || \
- (!inc_func && stt == STT_FUNC ) || \
- (!inc_file && stt == STT_FILE ) || \
- (!inc_local && stb == STB_LOCAL ) || \
- (!inc_global && stb == STB_GLOBAL) || \
- (!inc_weak && stb == STB_WEAK ) || \
+ if ((!inc_notype && stt == STT_NOTYPE ) || \
+ (!inc_object && stt == STT_OBJECT ) || \
+ (!inc_func && stt == STT_FUNC ) || \
+ (!inc_file && stt == STT_FILE ) || \
+ (!inc_local && stb == STB_LOCAL ) || \
+ (!inc_global && stb == STB_GLOBAL ) || \
+ (!inc_weak && stb == STB_WEAK ) || \
+ (!inc_visdef && stv == STV_DEFAULT ) || \
+ (!inc_intern && stv == STV_INTERNAL ) || \
+ (!inc_hidden && stv == STV_HIDDEN ) || \
+ (!inc_prot && stv == STV_PROTECTED) || \
(!inc_def && shn && shn < SHN_LORESERVE) || \
- (!inc_undef && shn == SHN_UNDEF ) || \
- (!inc_abs && shn == SHN_ABS ) || \
- (!inc_common && shn == SHN_COMMON))
+ (!inc_undef && shn == SHN_UNDEF ) || \
+ (!inc_abs && shn == SHN_ABS ) || \
+ (!inc_common && shn == SHN_COMMON ))
continue;
if (*this_sym == '*') {
/* a "*" symbol gets you debug output */
- printf("%s(%s) %5lX %15s %15s %15s %s\n",
+ printf("%s(%s) %5lX %-15s %-15s %-15s %-15s %s\n",
((*found_sym == 0) ? "\n\t" : "\t"),
elf->base_filename,
size,
get_elfstttype(stt),
get_elfstbtype(stb),
+ get_elfstvtype(stv),
get_elfshntype(shn),
symname);
goto matched;
@@ -1370,6 +1384,7 @@
&ret, &ret_len, symname, \
ELF##B##_ST_TYPE(EGET(sym->st_info)), \
ELF##B##_ST_BIND(EGET(sym->st_info)), \
+ ELF##B##_ST_VISIBILITY(EGET(sym->st_other)), \
EGET(sym->st_shndx), \
/* st_size can be 64bit, but no one is really that big, so screw em */ \
EGET(sym->st_size)); \
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-06-18 3:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-28 5:14 [gentoo-commits] gentoo-projects commit in pax-utils: paxelf.c paxelf.h scanelf.c Mike Frysinger (vapier)
-- strict thread matches above, loose matches on Subject: below --
2014-06-18 3:16 Mike Frysinger (vapier)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox