Move code to disable ASR to nat/
This patch moves the shared code present on gdb/linux-nat.c:linux_nat_create_inferior and gdb/gdbserver/linux-low.c:linux_create_inferior to nat/linux-personality.c. This code is responsible for disabling address space randomization based on user setting, and using <sys/personality.h> to do that. I decided to put the prototype of the maybe_disable_address_space_randomization on nat/linux-osdata.h because it seemed the best place to put it. I regression-tested this patch on Fedora 20 x86_64, and found no regressions. gdb/ChangeLog 2015-01-15 Sergio Durigan Junior <sergiodj@redhat.com> * Makefile.in (HFILES_NO_SRCDIR): Add nat/linux-personality.h. (linux-personality.o): New rule. * common/common-defs.h: Include <stdint.h>. * config/aarch64/linux.mh (NATDEPFILES): Include linux-personality.o. * config/alpha/alpha-linux.mh (NATDEPFILES): Likewise. * config/arm/linux.mh (NATDEPFILES): Likewise. * config/i386/linux64.mh (NATDEPFILES): Likewise. * config/i386/linux.mh (NATDEPFILES): Likewise. * config/ia64/linux.mh (NATDEPFILES): Likewise. * config/m32r/linux.mh (NATDEPFILES): Likewise. * config/m68k/linux.mh (NATDEPFILES): Likewise. * config/mips/linux.mh (NATDEPFILES): Likewise. * config/pa/linux.mh (NATDEPFILES): Likewise. * config/powerpc/linux.mh (NATDEPFILES): Likewise. * config/powerpc/ppc64-linux.mh (NATDEPFILES): Likewise. * config/powerpc/spu-linux.mh (NATDEPFILES): Likewise. * config/s390/linux.mh (NATDEPFILES): Likewise. * config/sparc/linux64.mh (NATDEPFILES): Likewise. * config/sparc/linux.mh (NATDEPFILES): Likewise. * config/tilegx/linux.mh (NATDEPFILES): Likewise. * config/xtensa/linux.mh (NATDEPFILES): Likewise. * defs.h: Remove #include <stdint.h> (moved to common/common-defs.h). * linux-nat.c: Include nat/linux-personality.h. Remove #include <sys/personality.h>; do not define ADDR_NO_RANDOMIZE (moved to nat/linux-personality.c). (linux_nat_create_inferior): Remove code to disable address space randomization (moved to nat/linux-personality.c). Create cleanup to disable address space randomization. * nat/linux-personality.c: New file. * nat/linux-personality.h: Likewise. gdb/gdbserver/ChangeLog 2015-01-15 Sergio Durigan Junior <sergiodj@redhat.com> * Makefile.in (SFILES): Add linux-personality.c. (linux-personality.o): New rule. * configure.srv (srv_linux_obj): Add linux-personality.o to the list of objects to be built. * linux-low.c: Include nat/linux-personality.h. (linux_create_inferior): Remove code to disable address space randomization (moved to ../nat/linux-personality.c). Create cleanup to disable address space randomization.
This commit is contained in:
parent
fb23d55442
commit
8cc73a3902
29 changed files with 213 additions and 84 deletions
|
@ -1,3 +1,38 @@
|
||||||
|
2015-01-15 Sergio Durigan Junior <sergiodj@redhat.com>
|
||||||
|
|
||||||
|
* Makefile.in (HFILES_NO_SRCDIR): Add nat/linux-personality.h.
|
||||||
|
(linux-personality.o): New rule.
|
||||||
|
* common/common-defs.h: Include <stdint.h>.
|
||||||
|
* config/aarch64/linux.mh (NATDEPFILES): Include
|
||||||
|
linux-personality.o.
|
||||||
|
* config/alpha/alpha-linux.mh (NATDEPFILES): Likewise.
|
||||||
|
* config/arm/linux.mh (NATDEPFILES): Likewise.
|
||||||
|
* config/i386/linux64.mh (NATDEPFILES): Likewise.
|
||||||
|
* config/i386/linux.mh (NATDEPFILES): Likewise.
|
||||||
|
* config/ia64/linux.mh (NATDEPFILES): Likewise.
|
||||||
|
* config/m32r/linux.mh (NATDEPFILES): Likewise.
|
||||||
|
* config/m68k/linux.mh (NATDEPFILES): Likewise.
|
||||||
|
* config/mips/linux.mh (NATDEPFILES): Likewise.
|
||||||
|
* config/pa/linux.mh (NATDEPFILES): Likewise.
|
||||||
|
* config/powerpc/linux.mh (NATDEPFILES): Likewise.
|
||||||
|
* config/powerpc/ppc64-linux.mh (NATDEPFILES): Likewise.
|
||||||
|
* config/powerpc/spu-linux.mh (NATDEPFILES): Likewise.
|
||||||
|
* config/s390/linux.mh (NATDEPFILES): Likewise.
|
||||||
|
* config/sparc/linux64.mh (NATDEPFILES): Likewise.
|
||||||
|
* config/sparc/linux.mh (NATDEPFILES): Likewise.
|
||||||
|
* config/tilegx/linux.mh (NATDEPFILES): Likewise.
|
||||||
|
* config/xtensa/linux.mh (NATDEPFILES): Likewise.
|
||||||
|
* defs.h: Remove #include <stdint.h> (moved to
|
||||||
|
common/common-defs.h).
|
||||||
|
* linux-nat.c: Include nat/linux-personality.h. Remove #include
|
||||||
|
<sys/personality.h>; do not define ADDR_NO_RANDOMIZE (moved to
|
||||||
|
nat/linux-personality.c).
|
||||||
|
(linux_nat_create_inferior): Remove code to disable address space
|
||||||
|
randomization (moved to nat/linux-personality.c). Create cleanup
|
||||||
|
to disable address space randomization.
|
||||||
|
* nat/linux-personality.c: New file.
|
||||||
|
* nat/linux-personality.h: Likewise.
|
||||||
|
|
||||||
2015-01-15 Sergio Durigan Junior <sergiodj@redhat.com>
|
2015-01-15 Sergio Durigan Junior <sergiodj@redhat.com>
|
||||||
|
|
||||||
* Makefile.in (ALLDEPFILES): Including common/mingw-strerror.c and
|
* Makefile.in (ALLDEPFILES): Including common/mingw-strerror.c and
|
||||||
|
|
|
@ -961,7 +961,7 @@ common/print-utils.h common/rsp-low.h nat/x86-dregs.h x86-linux-nat.h \
|
||||||
i386-linux-nat.h common/common-defs.h common/errors.h common/common-types.h \
|
i386-linux-nat.h common/common-defs.h common/errors.h common/common-types.h \
|
||||||
common/common-debug.h common/cleanups.h common/gdb_setjmp.h \
|
common/common-debug.h common/cleanups.h common/gdb_setjmp.h \
|
||||||
common/common-exceptions.h target/target.h common/symbol.h \
|
common/common-exceptions.h target/target.h common/symbol.h \
|
||||||
common/common-regcache.h fbsd-tdep.h
|
common/common-regcache.h fbsd-tdep.h nat/linux-personality.h
|
||||||
|
|
||||||
# Header files that already have srcdir in them, or which are in objdir.
|
# Header files that already have srcdir in them, or which are in objdir.
|
||||||
|
|
||||||
|
@ -2282,6 +2282,10 @@ ppc-linux.o: ${srcdir}/nat/ppc-linux.c
|
||||||
$(COMPILE) $(srcdir)/nat/ppc-linux.c
|
$(COMPILE) $(srcdir)/nat/ppc-linux.c
|
||||||
$(POSTCOMPILE)
|
$(POSTCOMPILE)
|
||||||
|
|
||||||
|
linux-personality.o: ${srcdir}/nat/linux-personality.c
|
||||||
|
$(COMPILE) $(srcdir)/nat/linux-personality.c
|
||||||
|
$(POSTCOMPILE)
|
||||||
|
|
||||||
#
|
#
|
||||||
# gdb/tui/ dependencies
|
# gdb/tui/ dependencies
|
||||||
#
|
#
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <alloca.h>
|
#include <alloca.h>
|
||||||
|
|
|
@ -21,7 +21,8 @@
|
||||||
NAT_FILE= config/nm-linux.h
|
NAT_FILE= config/nm-linux.h
|
||||||
NATDEPFILES= inf-ptrace.o fork-child.o aarch64-linux-nat.o \
|
NATDEPFILES= inf-ptrace.o fork-child.o aarch64-linux-nat.o \
|
||||||
proc-service.o linux-thread-db.o linux-nat.o linux-fork.o \
|
proc-service.o linux-thread-db.o linux-nat.o linux-fork.o \
|
||||||
linux-procfs.o linux-ptrace.o linux-osdata.o linux-waitpid.o
|
linux-procfs.o linux-ptrace.o linux-osdata.o linux-waitpid.o \
|
||||||
|
linux-personality.o
|
||||||
NAT_CDEPS = $(srcdir)/proc-service.list
|
NAT_CDEPS = $(srcdir)/proc-service.list
|
||||||
|
|
||||||
LOADLIBES= -ldl $(RDYNAMIC)
|
LOADLIBES= -ldl $(RDYNAMIC)
|
||||||
|
|
|
@ -3,7 +3,7 @@ NAT_FILE= config/nm-linux.h
|
||||||
NATDEPFILES= inf-ptrace.o alpha-linux-nat.o \
|
NATDEPFILES= inf-ptrace.o alpha-linux-nat.o \
|
||||||
fork-child.o proc-service.o linux-thread-db.o \
|
fork-child.o proc-service.o linux-thread-db.o \
|
||||||
linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o \
|
linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o \
|
||||||
linux-waitpid.o
|
linux-waitpid.o linux-personality.o
|
||||||
NAT_CDEPS = $(srcdir)/proc-service.list
|
NAT_CDEPS = $(srcdir)/proc-service.list
|
||||||
|
|
||||||
# The dynamically loaded libthread_db needs access to symbols in the
|
# The dynamically loaded libthread_db needs access to symbols in the
|
||||||
|
|
|
@ -4,7 +4,7 @@ NAT_FILE= config/nm-linux.h
|
||||||
NATDEPFILES= inf-ptrace.o fork-child.o arm-linux-nat.o \
|
NATDEPFILES= inf-ptrace.o fork-child.o arm-linux-nat.o \
|
||||||
proc-service.o linux-thread-db.o \
|
proc-service.o linux-thread-db.o \
|
||||||
linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o \
|
linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o \
|
||||||
linux-waitpid.o
|
linux-waitpid.o linux-personality.o
|
||||||
NAT_CDEPS = $(srcdir)/proc-service.list
|
NAT_CDEPS = $(srcdir)/proc-service.list
|
||||||
|
|
||||||
LOADLIBES= -ldl $(RDYNAMIC)
|
LOADLIBES= -ldl $(RDYNAMIC)
|
||||||
|
|
|
@ -5,7 +5,7 @@ NATDEPFILES= inf-ptrace.o fork-child.o \
|
||||||
x86-nat.o x86-dregs.o i386-linux-nat.o x86-linux-nat.o \
|
x86-nat.o x86-dregs.o i386-linux-nat.o x86-linux-nat.o \
|
||||||
proc-service.o linux-thread-db.o \
|
proc-service.o linux-thread-db.o \
|
||||||
linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o \
|
linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o \
|
||||||
linux-btrace.o linux-waitpid.o
|
linux-btrace.o linux-waitpid.o linux-personality.o
|
||||||
NAT_CDEPS = $(srcdir)/proc-service.list
|
NAT_CDEPS = $(srcdir)/proc-service.list
|
||||||
|
|
||||||
# The dynamically loaded libthread_db needs access to symbols in the
|
# The dynamically loaded libthread_db needs access to symbols in the
|
||||||
|
|
|
@ -5,7 +5,7 @@ NATDEPFILES= inf-ptrace.o fork-child.o \
|
||||||
linux-nat.o linux-osdata.o \
|
linux-nat.o linux-osdata.o \
|
||||||
proc-service.o linux-thread-db.o linux-fork.o \
|
proc-service.o linux-thread-db.o linux-fork.o \
|
||||||
linux-procfs.o linux-ptrace.o linux-btrace.o \
|
linux-procfs.o linux-ptrace.o linux-btrace.o \
|
||||||
linux-waitpid.o
|
linux-waitpid.o linux-personality.o
|
||||||
NAT_FILE= config/nm-linux.h
|
NAT_FILE= config/nm-linux.h
|
||||||
NAT_CDEPS = $(srcdir)/proc-service.list
|
NAT_CDEPS = $(srcdir)/proc-service.list
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ NATDEPFILES= inf-ptrace.o fork-child.o \
|
||||||
ia64-linux-nat.o \
|
ia64-linux-nat.o \
|
||||||
proc-service.o linux-thread-db.o \
|
proc-service.o linux-thread-db.o \
|
||||||
linux-nat.o linux-osdata.o linux-fork.o \
|
linux-nat.o linux-osdata.o linux-fork.o \
|
||||||
|
linux-personality.o \
|
||||||
linux-procfs.o linux-ptrace.o linux-waitpid.o
|
linux-procfs.o linux-ptrace.o linux-waitpid.o
|
||||||
NAT_CDEPS = $(srcdir)/proc-service.list
|
NAT_CDEPS = $(srcdir)/proc-service.list
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ NAT_FILE= config/nm-linux.h
|
||||||
NATDEPFILES= inf-ptrace.o fork-child.o \
|
NATDEPFILES= inf-ptrace.o fork-child.o \
|
||||||
m32r-linux-nat.o proc-service.o linux-thread-db.o \
|
m32r-linux-nat.o proc-service.o linux-thread-db.o \
|
||||||
linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o \
|
linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o \
|
||||||
linux-waitpid.o
|
linux-waitpid.o linux-personality.o
|
||||||
NAT_CDEPS = $(srcdir)/proc-service.list
|
NAT_CDEPS = $(srcdir)/proc-service.list
|
||||||
|
|
||||||
LOADLIBES= -ldl $(RDYNAMIC)
|
LOADLIBES= -ldl $(RDYNAMIC)
|
||||||
|
|
|
@ -5,6 +5,7 @@ NATDEPFILES= inf-ptrace.o fork-child.o \
|
||||||
m68klinux-nat.o \
|
m68klinux-nat.o \
|
||||||
proc-service.o linux-thread-db.o \
|
proc-service.o linux-thread-db.o \
|
||||||
linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o \
|
linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o \
|
||||||
|
linux-personality.o \
|
||||||
linux-waitpid.o
|
linux-waitpid.o
|
||||||
NAT_CDEPS = $(srcdir)/proc-service.list
|
NAT_CDEPS = $(srcdir)/proc-service.list
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ NATDEPFILES= inf-ptrace.o fork-child.o mips-linux-nat.o \
|
||||||
linux-thread-db.o proc-service.o \
|
linux-thread-db.o proc-service.o \
|
||||||
linux-nat.o linux-osdata.o linux-fork.o \
|
linux-nat.o linux-osdata.o linux-fork.o \
|
||||||
linux-procfs.o linux-ptrace.o linux-waitpid.o \
|
linux-procfs.o linux-ptrace.o linux-waitpid.o \
|
||||||
|
linux-personality.o \
|
||||||
mips-linux-watch.o
|
mips-linux-watch.o
|
||||||
NAT_CDEPS = $(srcdir)/proc-service.list
|
NAT_CDEPS = $(srcdir)/proc-service.list
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,8 @@ NAT_FILE= config/nm-linux.h
|
||||||
NATDEPFILES= inf-ptrace.o fork-child.o \
|
NATDEPFILES= inf-ptrace.o fork-child.o \
|
||||||
hppa-linux-nat.o proc-service.o linux-thread-db.o \
|
hppa-linux-nat.o proc-service.o linux-thread-db.o \
|
||||||
linux-nat.o linux-osdata.o linux-fork.o \
|
linux-nat.o linux-osdata.o linux-fork.o \
|
||||||
linux-procfs.o linux-ptrace.o linux-waitpid.o
|
linux-procfs.o linux-ptrace.o linux-waitpid.o \
|
||||||
|
linux-personality.o
|
||||||
NAT_CDEPS = $(srcdir)/proc-service.list
|
NAT_CDEPS = $(srcdir)/proc-service.list
|
||||||
|
|
||||||
LOADLIBES = -ldl $(RDYNAMIC)
|
LOADLIBES = -ldl $(RDYNAMIC)
|
||||||
|
|
|
@ -6,7 +6,7 @@ NAT_FILE= config/nm-linux.h
|
||||||
NATDEPFILES= inf-ptrace.o fork-child.o \
|
NATDEPFILES= inf-ptrace.o fork-child.o \
|
||||||
ppc-linux-nat.o proc-service.o linux-thread-db.o \
|
ppc-linux-nat.o proc-service.o linux-thread-db.o \
|
||||||
linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o \
|
linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o \
|
||||||
linux-waitpid.o
|
linux-waitpid.o linux-personality.o
|
||||||
NAT_CDEPS = $(srcdir)/proc-service.list
|
NAT_CDEPS = $(srcdir)/proc-service.list
|
||||||
|
|
||||||
LOADLIBES = -ldl $(RDYNAMIC)
|
LOADLIBES = -ldl $(RDYNAMIC)
|
||||||
|
|
|
@ -6,7 +6,7 @@ NAT_FILE= config/nm-linux.h
|
||||||
NATDEPFILES= inf-ptrace.o fork-child.o \
|
NATDEPFILES= inf-ptrace.o fork-child.o \
|
||||||
ppc-linux-nat.o proc-service.o linux-thread-db.o \
|
ppc-linux-nat.o proc-service.o linux-thread-db.o \
|
||||||
linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o \
|
linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o \
|
||||||
linux-waitpid.o ppc-linux.o
|
linux-waitpid.o ppc-linux.o linux-personality.o
|
||||||
NAT_CDEPS = $(srcdir)/proc-service.list
|
NAT_CDEPS = $(srcdir)/proc-service.list
|
||||||
|
|
||||||
# The PowerPC has severe limitations on TOC size, and uses them even
|
# The PowerPC has severe limitations on TOC size, and uses them even
|
||||||
|
|
|
@ -4,5 +4,5 @@
|
||||||
# PPU side of the Cell BE and debugging the SPU side.
|
# PPU side of the Cell BE and debugging the SPU side.
|
||||||
|
|
||||||
NATDEPFILES = spu-linux-nat.o fork-child.o inf-ptrace.o \
|
NATDEPFILES = spu-linux-nat.o fork-child.o inf-ptrace.o \
|
||||||
linux-procfs.o linux-ptrace.o linux-waitpid.o
|
linux-procfs.o linux-ptrace.o linux-waitpid.o linux-personality.o
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ NAT_FILE= config/nm-linux.h
|
||||||
NATDEPFILES= inf-ptrace.o fork-child.o s390-linux-nat.o \
|
NATDEPFILES= inf-ptrace.o fork-child.o s390-linux-nat.o \
|
||||||
linux-thread-db.o proc-service.o \
|
linux-thread-db.o proc-service.o \
|
||||||
linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o \
|
linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o \
|
||||||
|
linux-personality.o \
|
||||||
linux-waitpid.o
|
linux-waitpid.o
|
||||||
NAT_CDEPS = $(srcdir)/proc-service.list
|
NAT_CDEPS = $(srcdir)/proc-service.list
|
||||||
LOADLIBES = -ldl $(RDYNAMIC)
|
LOADLIBES = -ldl $(RDYNAMIC)
|
||||||
|
|
|
@ -4,7 +4,8 @@ NATDEPFILES= sparc-nat.o sparc-linux-nat.o \
|
||||||
fork-child.o inf-ptrace.o \
|
fork-child.o inf-ptrace.o \
|
||||||
proc-service.o linux-thread-db.o \
|
proc-service.o linux-thread-db.o \
|
||||||
linux-nat.o linux-osdata.o linux-fork.o \
|
linux-nat.o linux-osdata.o linux-fork.o \
|
||||||
linux-procfs.o linux-ptrace.o linux-waitpid.o
|
linux-procfs.o linux-ptrace.o linux-waitpid.o \
|
||||||
|
linux-personality.o
|
||||||
NAT_CDEPS = $(srcdir)/proc-service.list
|
NAT_CDEPS = $(srcdir)/proc-service.list
|
||||||
|
|
||||||
# The dynamically loaded libthread_db needs access to symbols in the
|
# The dynamically loaded libthread_db needs access to symbols in the
|
||||||
|
|
|
@ -4,7 +4,8 @@ NATDEPFILES= sparc-nat.o sparc64-nat.o sparc64-linux-nat.o \
|
||||||
fork-child.o inf-ptrace.o \
|
fork-child.o inf-ptrace.o \
|
||||||
proc-service.o linux-thread-db.o \
|
proc-service.o linux-thread-db.o \
|
||||||
linux-nat.o linux-osdata.o linux-fork.o \
|
linux-nat.o linux-osdata.o linux-fork.o \
|
||||||
linux-procfs.o linux-ptrace.o linux-waitpid.o
|
linux-procfs.o linux-ptrace.o linux-waitpid.o \
|
||||||
|
linux-personality.o
|
||||||
NAT_CDEPS = $(srcdir)/proc-service.list
|
NAT_CDEPS = $(srcdir)/proc-service.list
|
||||||
|
|
||||||
# The dynamically loaded libthread_db needs access to symbols in the
|
# The dynamically loaded libthread_db needs access to symbols in the
|
||||||
|
|
|
@ -5,7 +5,8 @@ NATDEPFILES= inf-ptrace.o fork-child.o \
|
||||||
tilegx-linux-nat.o \
|
tilegx-linux-nat.o \
|
||||||
proc-service.o linux-thread-db.o \
|
proc-service.o linux-thread-db.o \
|
||||||
linux-nat.o linux-osdata.o linux-fork.o \
|
linux-nat.o linux-osdata.o linux-fork.o \
|
||||||
linux-procfs.o linux-ptrace.o linux-waitpid.o
|
linux-procfs.o linux-ptrace.o linux-waitpid.o \
|
||||||
|
linux-personality.o
|
||||||
|
|
||||||
# The dynamically loaded libthread_db needs access to symbols in the
|
# The dynamically loaded libthread_db needs access to symbols in the
|
||||||
# gdb executable.
|
# gdb executable.
|
||||||
|
|
|
@ -5,7 +5,7 @@ NAT_FILE= config/nm-linux.h
|
||||||
NATDEPFILES= inf-ptrace.o fork-child.o xtensa-linux-nat.o \
|
NATDEPFILES= inf-ptrace.o fork-child.o xtensa-linux-nat.o \
|
||||||
linux-thread-db.o proc-service.o \
|
linux-thread-db.o proc-service.o \
|
||||||
linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o \
|
linux-nat.o linux-osdata.o linux-fork.o linux-procfs.o linux-ptrace.o \
|
||||||
linux-waitpid.o
|
linux-waitpid.o linux-personality.o
|
||||||
NAT_CDEPS = $(srcdir)/proc-service.list
|
NAT_CDEPS = $(srcdir)/proc-service.list
|
||||||
|
|
||||||
LOADLIBES = -ldl $(RDYNAMIC)
|
LOADLIBES = -ldl $(RDYNAMIC)
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
/* The libdecnumber library, on which GDB depends, includes a header file
|
/* The libdecnumber library, on which GDB depends, includes a header file
|
||||||
called gstdint.h instead of relying directly on stdint.h. GDB, on the
|
called gstdint.h instead of relying directly on stdint.h. GDB, on the
|
||||||
|
|
|
@ -1,3 +1,14 @@
|
||||||
|
2015-01-15 Sergio Durigan Junior <sergiodj@redhat.com>
|
||||||
|
|
||||||
|
* Makefile.in (SFILES): Add linux-personality.c.
|
||||||
|
(linux-personality.o): New rule.
|
||||||
|
* configure.srv (srv_linux_obj): Add linux-personality.o to the
|
||||||
|
list of objects to be built.
|
||||||
|
* linux-low.c: Include nat/linux-personality.h.
|
||||||
|
(linux_create_inferior): Remove code to disable address space
|
||||||
|
randomization (moved to ../nat/linux-personality.c). Create
|
||||||
|
cleanup to disable address space randomization.
|
||||||
|
|
||||||
2015-01-15 Sergio Durigan Junior <sergiodj@redhat.com>
|
2015-01-15 Sergio Durigan Junior <sergiodj@redhat.com>
|
||||||
|
|
||||||
* Makefile.in (posix-strerror.o): New rule.
|
* Makefile.in (posix-strerror.o): New rule.
|
||||||
|
|
|
@ -167,6 +167,7 @@ SFILES= $(srcdir)/gdbreplay.c $(srcdir)/inferiors.c $(srcdir)/dll.c \
|
||||||
$(srcdir)/common/vec.c $(srcdir)/common/gdb_vecs.c \
|
$(srcdir)/common/vec.c $(srcdir)/common/gdb_vecs.c \
|
||||||
$(srcdir)/common/common-utils.c $(srcdir)/common/xml-utils.c \
|
$(srcdir)/common/common-utils.c $(srcdir)/common/xml-utils.c \
|
||||||
$(srcdir)/nat/linux-osdata.c $(srcdir)/common/ptid.c \
|
$(srcdir)/nat/linux-osdata.c $(srcdir)/common/ptid.c \
|
||||||
|
$(srcdir)/nat/linux-personality.c \
|
||||||
$(srcdir)/common/buffer.c $(srcdir)/nat/linux-btrace.c \
|
$(srcdir)/common/buffer.c $(srcdir)/nat/linux-btrace.c \
|
||||||
$(srcdir)/common/filestuff.c $(srcdir)/target/waitstatus.c \
|
$(srcdir)/common/filestuff.c $(srcdir)/target/waitstatus.c \
|
||||||
$(srcdir)/nat/mips-linux-watch.c $(srcdir)/common/print-utils.c \
|
$(srcdir)/nat/mips-linux-watch.c $(srcdir)/common/print-utils.c \
|
||||||
|
@ -590,6 +591,9 @@ mips-linux-watch.o: ../nat/mips-linux-watch.c
|
||||||
ppc-linux.o: ../nat/ppc-linux.c
|
ppc-linux.o: ../nat/ppc-linux.c
|
||||||
$(COMPILE) $<
|
$(COMPILE) $<
|
||||||
$(POSTCOMPILE)
|
$(POSTCOMPILE)
|
||||||
|
linux-personality.o: ../nat/linux-personality.c
|
||||||
|
$(COMPILE) $<
|
||||||
|
$(POSTCOMPILE)
|
||||||
|
|
||||||
aarch64.c : $(srcdir)/../regformats/aarch64.dat $(regdat_sh)
|
aarch64.c : $(srcdir)/../regformats/aarch64.dat $(regdat_sh)
|
||||||
$(SHELL) $(regdat_sh) $(srcdir)/../regformats/aarch64.dat aarch64.c
|
$(SHELL) $(regdat_sh) $(srcdir)/../regformats/aarch64.dat aarch64.c
|
||||||
|
|
|
@ -42,7 +42,7 @@ srv_amd64_linux_xmlfiles="i386/amd64-linux.xml i386/amd64-avx-linux.xml i386/amd
|
||||||
|
|
||||||
# Linux object files. This is so we don't have to repeat
|
# Linux object files. This is so we don't have to repeat
|
||||||
# these files over and over again.
|
# these files over and over again.
|
||||||
srv_linux_obj="linux-low.o linux-osdata.o linux-procfs.o linux-ptrace.o linux-waitpid.o"
|
srv_linux_obj="linux-low.o linux-osdata.o linux-procfs.o linux-ptrace.o linux-waitpid.o linux-personality.o"
|
||||||
|
|
||||||
# Input is taken from the "${target}" variable.
|
# Input is taken from the "${target}" variable.
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include <sys/ptrace.h>
|
#include <sys/ptrace.h>
|
||||||
#include "nat/linux-ptrace.h"
|
#include "nat/linux-ptrace.h"
|
||||||
#include "nat/linux-procfs.h"
|
#include "nat/linux-procfs.h"
|
||||||
|
#include "nat/linux-personality.h"
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
@ -597,29 +598,11 @@ add_lwp (ptid_t ptid)
|
||||||
static int
|
static int
|
||||||
linux_create_inferior (char *program, char **allargs)
|
linux_create_inferior (char *program, char **allargs)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_PERSONALITY
|
|
||||||
int personality_orig = 0, personality_set = 0;
|
|
||||||
#endif
|
|
||||||
struct lwp_info *new_lwp;
|
struct lwp_info *new_lwp;
|
||||||
int pid;
|
int pid;
|
||||||
ptid_t ptid;
|
ptid_t ptid;
|
||||||
|
struct cleanup *restore_personality
|
||||||
#ifdef HAVE_PERSONALITY
|
= maybe_disable_address_space_randomization (disable_randomization);
|
||||||
if (disable_randomization)
|
|
||||||
{
|
|
||||||
errno = 0;
|
|
||||||
personality_orig = personality (0xffffffff);
|
|
||||||
if (errno == 0 && !(personality_orig & ADDR_NO_RANDOMIZE))
|
|
||||||
{
|
|
||||||
personality_set = 1;
|
|
||||||
personality (personality_orig | ADDR_NO_RANDOMIZE);
|
|
||||||
}
|
|
||||||
if (errno != 0 || (personality_set
|
|
||||||
&& !(personality (0xffffffff) & ADDR_NO_RANDOMIZE)))
|
|
||||||
warning ("Error disabling address space randomization: %s",
|
|
||||||
strerror (errno));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(__UCLIBC__) && defined(HAS_NOMMU)
|
#if defined(__UCLIBC__) && defined(HAS_NOMMU)
|
||||||
pid = vfork ();
|
pid = vfork ();
|
||||||
|
@ -665,16 +648,7 @@ linux_create_inferior (char *program, char **allargs)
|
||||||
_exit (0177);
|
_exit (0177);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_PERSONALITY
|
do_cleanups (restore_personality);
|
||||||
if (personality_set)
|
|
||||||
{
|
|
||||||
errno = 0;
|
|
||||||
personality (personality_orig);
|
|
||||||
if (errno != 0)
|
|
||||||
warning ("Error restoring address space randomization: %s",
|
|
||||||
strerror (errno));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
linux_add_process (pid, 0);
|
linux_add_process (pid, 0);
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@
|
||||||
#include "linux-nat.h"
|
#include "linux-nat.h"
|
||||||
#include "nat/linux-ptrace.h"
|
#include "nat/linux-ptrace.h"
|
||||||
#include "nat/linux-procfs.h"
|
#include "nat/linux-procfs.h"
|
||||||
|
#include "nat/linux-personality.h"
|
||||||
#include "linux-fork.h"
|
#include "linux-fork.h"
|
||||||
#include "gdbthread.h"
|
#include "gdbthread.h"
|
||||||
#include "gdbcmd.h"
|
#include "gdbcmd.h"
|
||||||
|
@ -70,13 +71,6 @@
|
||||||
#define SPUFS_MAGIC 0x23c9b64e
|
#define SPUFS_MAGIC 0x23c9b64e
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_PERSONALITY
|
|
||||||
# include <sys/personality.h>
|
|
||||||
# if !HAVE_DECL_ADDR_NO_RANDOMIZE
|
|
||||||
# define ADDR_NO_RANDOMIZE 0x0040000
|
|
||||||
# endif
|
|
||||||
#endif /* HAVE_PERSONALITY */
|
|
||||||
|
|
||||||
/* This comment documents high-level logic of this file.
|
/* This comment documents high-level logic of this file.
|
||||||
|
|
||||||
Waiting for events in sync mode
|
Waiting for events in sync mode
|
||||||
|
@ -1103,45 +1097,18 @@ linux_nat_create_inferior (struct target_ops *ops,
|
||||||
char *exec_file, char *allargs, char **env,
|
char *exec_file, char *allargs, char **env,
|
||||||
int from_tty)
|
int from_tty)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_PERSONALITY
|
struct cleanup *restore_personality
|
||||||
int personality_orig = 0, personality_set = 0;
|
= maybe_disable_address_space_randomization (disable_randomization);
|
||||||
#endif /* HAVE_PERSONALITY */
|
|
||||||
|
|
||||||
/* The fork_child mechanism is synchronous and calls target_wait, so
|
/* The fork_child mechanism is synchronous and calls target_wait, so
|
||||||
we have to mask the async mode. */
|
we have to mask the async mode. */
|
||||||
|
|
||||||
#ifdef HAVE_PERSONALITY
|
|
||||||
if (disable_randomization)
|
|
||||||
{
|
|
||||||
errno = 0;
|
|
||||||
personality_orig = personality (0xffffffff);
|
|
||||||
if (errno == 0 && !(personality_orig & ADDR_NO_RANDOMIZE))
|
|
||||||
{
|
|
||||||
personality_set = 1;
|
|
||||||
personality (personality_orig | ADDR_NO_RANDOMIZE);
|
|
||||||
}
|
|
||||||
if (errno != 0 || (personality_set
|
|
||||||
&& !(personality (0xffffffff) & ADDR_NO_RANDOMIZE)))
|
|
||||||
warning (_("Error disabling address space randomization: %s"),
|
|
||||||
safe_strerror (errno));
|
|
||||||
}
|
|
||||||
#endif /* HAVE_PERSONALITY */
|
|
||||||
|
|
||||||
/* Make sure we report all signals during startup. */
|
/* Make sure we report all signals during startup. */
|
||||||
linux_nat_pass_signals (ops, 0, NULL);
|
linux_nat_pass_signals (ops, 0, NULL);
|
||||||
|
|
||||||
linux_ops->to_create_inferior (ops, exec_file, allargs, env, from_tty);
|
linux_ops->to_create_inferior (ops, exec_file, allargs, env, from_tty);
|
||||||
|
|
||||||
#ifdef HAVE_PERSONALITY
|
do_cleanups (restore_personality);
|
||||||
if (personality_set)
|
|
||||||
{
|
|
||||||
errno = 0;
|
|
||||||
personality (personality_orig);
|
|
||||||
if (errno != 0)
|
|
||||||
warning (_("Error restoring address space randomization: %s"),
|
|
||||||
safe_strerror (errno));
|
|
||||||
}
|
|
||||||
#endif /* HAVE_PERSONALITY */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Callback for linux_proc_attach_tgid_threads. Attach to PTID if not
|
/* Callback for linux_proc_attach_tgid_threads. Attach to PTID if not
|
||||||
|
|
94
gdb/nat/linux-personality.c
Normal file
94
gdb/nat/linux-personality.c
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
/* Disable address space randomization based on inferior personality.
|
||||||
|
|
||||||
|
Copyright (C) 2008-2015 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of GDB.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
#include "common-defs.h"
|
||||||
|
#include "nat/linux-personality.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_PERSONALITY
|
||||||
|
# include <sys/personality.h>
|
||||||
|
# ifndef HAVE_DECL_ADDR_NO_RANDOMIZE
|
||||||
|
# define ADDR_NO_RANDOMIZE 0x0040000
|
||||||
|
# endif /* ! HAVE_DECL_ADDR_NO_RANDOMIZE */
|
||||||
|
#endif /* HAVE_PERSONALITY */
|
||||||
|
|
||||||
|
#ifdef HAVE_PERSONALITY
|
||||||
|
|
||||||
|
/* Restore address space randomization of the inferior. ARG is the
|
||||||
|
original inferior's personality value before the address space
|
||||||
|
randomization was disabled. */
|
||||||
|
|
||||||
|
static void
|
||||||
|
restore_personality (void *arg)
|
||||||
|
{
|
||||||
|
int personality_orig = (int) (uintptr_t) arg;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
personality (personality_orig);
|
||||||
|
if (errno != 0)
|
||||||
|
warning (_("Error restoring address space randomization: %s"),
|
||||||
|
safe_strerror (errno));
|
||||||
|
}
|
||||||
|
#endif /* HAVE_PERSONALITY */
|
||||||
|
|
||||||
|
/* Return a cleanup responsible for restoring the inferior's
|
||||||
|
personality (and restoring the inferior's address space
|
||||||
|
randomization) if HAVE_PERSONALITY and if PERSONALITY_SET is not
|
||||||
|
zero; return a null cleanup if not HAVE_PERSONALITY or if
|
||||||
|
PERSONALITY_SET is zero. */
|
||||||
|
|
||||||
|
static struct cleanup *
|
||||||
|
make_disable_asr_cleanup (int personality_set, int personality_orig)
|
||||||
|
{
|
||||||
|
#ifdef HAVE_PERSONALITY
|
||||||
|
if (personality_set != 0)
|
||||||
|
return make_cleanup (restore_personality,
|
||||||
|
(void *) (uintptr_t) personality_orig);
|
||||||
|
#endif /* HAVE_PERSONALITY */
|
||||||
|
|
||||||
|
return make_cleanup (null_cleanup, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* See comment on nat/linux-personality.h. */
|
||||||
|
|
||||||
|
struct cleanup *
|
||||||
|
maybe_disable_address_space_randomization (int disable_randomization)
|
||||||
|
{
|
||||||
|
int personality_orig = 0;
|
||||||
|
int personality_set = 0;
|
||||||
|
|
||||||
|
#ifdef HAVE_PERSONALITY
|
||||||
|
if (disable_randomization)
|
||||||
|
{
|
||||||
|
errno = 0;
|
||||||
|
personality_orig = personality (0xffffffff);
|
||||||
|
if (errno == 0 && !(personality_orig & ADDR_NO_RANDOMIZE))
|
||||||
|
{
|
||||||
|
personality_set = 1;
|
||||||
|
personality (personality_orig | ADDR_NO_RANDOMIZE);
|
||||||
|
}
|
||||||
|
if (errno != 0 || (personality_set
|
||||||
|
&& !(personality (0xffffffff) & ADDR_NO_RANDOMIZE)))
|
||||||
|
warning (_("Error disabling address space randomization: %s"),
|
||||||
|
safe_strerror (errno));
|
||||||
|
}
|
||||||
|
#endif /* HAVE_PERSONALITY */
|
||||||
|
|
||||||
|
return make_disable_asr_cleanup (personality_set,
|
||||||
|
personality_orig);
|
||||||
|
}
|
31
gdb/nat/linux-personality.h
Normal file
31
gdb/nat/linux-personality.h
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
/* Disable address space randomization based on inferior personality.
|
||||||
|
|
||||||
|
Copyright (C) 2008-2015 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
This file is part of GDB.
|
||||||
|
|
||||||
|
This program is free software; you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation; either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||||
|
|
||||||
|
#ifndef NAT_LINUX_PERSONALITY_H
|
||||||
|
#define NAT_LINUX_PERSONALITY_H
|
||||||
|
|
||||||
|
/* Disable the inferior's address space randomization if
|
||||||
|
DISABLE_RANDOMIZATION is not zero and if we have
|
||||||
|
<sys/personality.h>. Return a cleanup which, when called, will
|
||||||
|
re-enable the inferior's address space randomization. */
|
||||||
|
|
||||||
|
extern struct cleanup *maybe_disable_address_space_randomization
|
||||||
|
(int disable_randomization);
|
||||||
|
|
||||||
|
#endif /* ! NAT_LINUX_PERSONALITY_H */
|
Loading…
Add table
Add a link
Reference in a new issue