[patch] Smaller gdb: -rdynamic -> -Wl,--dynamic-list

Jan Kratochvil
2010-05-13T13:18:54Z

Hi,

gdb currently has needlessly huge .dynsym and thus even huge the (on-demand
loaded) LOAD segment. With the attached patch it gets smaller:

-rwxr-xr-x 1 4524488 gdb-7.1-19.fc13.x86_64/usr/bin/gdb
-rwxr-xr-x 1 4266728 gdb-7.1-19dynamiclist.fc13.x86_64/usr/bin/gdb
-rw-r--r-- 1 2364656 gdb-7.1-19.fc13.x86_64.rpm
-rw-r--r-- 1 2274300 gdb-7.1-19dynamiclist.fc13.x86_64.rpm

I am not sure with the gdbserver/Makefile.in new CDEPS there. I have not
found it defined anywhere while it is used as the gdbserver target dependency.

I hope on the build hosts where -rdynamic was supported even
-Wl,--dynamic-list must be supported.

ps_get_thread_area is not always defined while the proc-service.list file
lists it. GNU ld does not seem to be concerned by undefined symbols.

No regressions on {x86_64,x86_64-m32,i686}-fedora12-linux-gnu.

Thanks,
Jan

gdb/
2010-05-13 Jan Kratochvil <jan.kratochvil@redhat.com>

* Makefile.in (SFILES): Add proc-service.list.
* config/alpha/alpha-linux.mh (NAT_CDEPS): New.
(LOADLIBES): Replace -rdynamic by -Wl,--dynamic-list=(...).
* config/arm/linux.mh: Likewise.
* config/i386/linux.mh: Likewise.
* config/i386/linux64.mh: Likewise.
* config/ia64/linux.mh: Likewise.
* config/m32r/linux.mh: Likewise.
* config/m68k/linux.mh: Likewise.
* config/mips/linux.mh: Likewise.
* config/pa/linux.mh: Likewise.
* config/powerpc/linux.mh: Likewise.
* config/powerpc/ppc64-linux.mh: Likewise.
* config/s390/s390.mh: Likewise.
* config/sparc/linux.mh: Likewise.
* config/sparc/linux64.mh: Likewise.
* config/xtensa/linux.mh: Likewise.
* proc-service.list: New.

gdb/gdbserver/
2010-05-13 Jan Kratochvil <jan.kratochvil@redhat.com>

* Makefile.in (INTERNAL_CFLAGS): Change the subst to @DYNAMIC_LIST@.
(SFILES): Add $(srcdir)/proc-service.list.
(CDEPS): New.
* configure.ac: Change RDYNAMIC to DYNAMIC_LIST. Change the test to
-Wl,--dynamic-list.
* configure: Regenerate.
* proc-service.list: New.

--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -683,7 +683,7 @@ SFILES = ada-exp.y ada-lang.c ada-typeprint.c ada-valprint.c ada-tasks.c \
objc-exp.y objc-lang.c \
objfiles.c osabi.c observer.c osdata.c \
p-exp.y p-lang.c p-typeprint.c p-valprint.c parse.c printcmd.c \
- progspace.c \
+ proc-service.list progspace.c \
prologue-value.c psymtab.c \
regcache.c reggroups.c remote.c remote-fileio.c reverse.c \
scm-exp.c scm-lang.c scm-valprint.c \
--- a/gdb/config/alpha/alpha-linux.mh
+++ b/gdb/config/alpha/alpha-linux.mh
@@ -3,10 +3,11 @@ NAT_FILE= config/nm-linux.h
NATDEPFILES= inf-ptrace.o corelow.o alpha-linux-nat.o \
fork-child.o proc-service.o linux-thread-db.o \
linux-nat.o linux-fork.o
+NAT_CDEPS = $(srcdir)/proc-service.list

# The dynamically loaded libthread_db needs access to symbols in the
# gdb executable.
-LOADLIBES = -ldl -rdynamic
+LOADLIBES = -ldl -Wl,--dynamic-list=$(srcdir)/proc-service.list

# doublest.c currently assumes some properties of FP arithmetic
# on the host which require this.
--- a/gdb/config/arm/linux.mh
+++ b/gdb/config/arm/linux.mh
@@ -3,5 +3,6 @@
NAT_FILE= config/nm-linux.h
NATDEPFILES= inf-ptrace.o fork-child.o arm-linux-nat.o \
proc-service.o linux-thread-db.o linux-nat.o linux-fork.o
+NAT_CDEPS = $(srcdir)/proc-service.list

-LOADLIBES= -ldl -rdynamic
+LOADLIBES= -ldl -Wl,--dynamic-list=$(srcdir)/proc-service.list
--- a/gdb/config/i386/linux.mh
+++ b/gdb/config/i386/linux.mh
@@ -5,7 +5,8 @@ NATDEPFILES= inf-ptrace.o fork-child.o \
i386-nat.o i386-linux-nat.o \
proc-service.o linux-thread-db.o \
linux-nat.o linux-fork.o
+NAT_CDEPS = $(srcdir)/proc-service.list

# The dynamically loaded libthread_db needs access to symbols in the
# gdb executable.
-LOADLIBES = -ldl -rdynamic
+LOADLIBES = -ldl -Wl,--dynamic-list=$(srcdir)/proc-service.list
--- a/gdb/config/i386/linux64.mh
+++ b/gdb/config/i386/linux64.mh
@@ -3,7 +3,8 @@ NATDEPFILES= inf-ptrace.o fork-child.o \
i386-nat.o amd64-nat.o amd64-linux-nat.o linux-nat.o \
proc-service.o linux-thread-db.o linux-fork.o
NAT_FILE= config/nm-linux.h
+NAT_CDEPS = $(srcdir)/proc-service.list

# The dynamically loaded libthread_db needs access to symbols in the
# gdb executable.
-LOADLIBES = -ldl -rdynamic
+LOADLIBES = -ldl -Wl,--dynamic-list=$(srcdir)/proc-service.list
--- a/gdb/config/ia64/linux.mh
+++ b/gdb/config/ia64/linux.mh
@@ -4,5 +4,6 @@ NAT_FILE= config/nm-linux.h
NATDEPFILES= inf-ptrace.o fork-child.o corelow.o \
core-regset.o ia64-linux-nat.o \
proc-service.o linux-thread-db.o linux-nat.o linux-fork.o
+NAT_CDEPS = $(srcdir)/proc-service.list

-LOADLIBES = -ldl -rdynamic
+LOADLIBES = -ldl -Wl,--dynamic-list=$(srcdir)/proc-service.list
--- a/gdb/config/m32r/linux.mh
+++ b/gdb/config/m32r/linux.mh
@@ -4,5 +4,6 @@ NAT_FILE= config/nm-linux.h
NATDEPFILES= inf-ptrace.o fork-child.o corelow.o \
m32r-linux-nat.o proc-service.o linux-thread-db.o \
linux-nat.o linux-fork.o
+NAT_CDEPS = $(srcdir)/proc-service.list

-LOADLIBES= -ldl -rdynamic
+LOADLIBES= -ldl -Wl,--dynamic-list=$(srcdir)/proc-service.list
--- a/gdb/config/m68k/linux.mh
+++ b/gdb/config/m68k/linux.mh
@@ -4,7 +4,8 @@ NAT_FILE= config/nm-linux.h
NATDEPFILES= inf-ptrace.o fork-child.o \
corelow.o m68klinux-nat.o \
proc-service.o linux-thread-db.o linux-nat.o linux-fork.o
+NAT_CDEPS = $(srcdir)/proc-service.list

# The dynamically loaded libthread_db needs access to symbols in the
# gdb executable.
-LOADLIBES = -ldl -rdynamic
+LOADLIBES = -ldl -Wl,--dynamic-list=$(srcdir)/proc-service.list
--- a/gdb/config/mips/linux.mh
+++ b/gdb/config/mips/linux.mh
@@ -3,5 +3,6 @@ NAT_FILE= config/nm-linux.h
NATDEPFILES= inf-ptrace.o fork-child.o mips-linux-nat.o \
linux-thread-db.o proc-service.o \
linux-nat.o linux-fork.o
+NAT_CDEPS = $(srcdir)/proc-service.list

-LOADLIBES = -ldl -rdynamic
+LOADLIBES = -ldl -Wl,--dynamic-list=$(srcdir)/proc-service.list
--- a/gdb/config/pa/linux.mh
+++ b/gdb/config/pa/linux.mh
@@ -3,5 +3,6 @@ NAT_FILE= config/nm-linux.h
NATDEPFILES= inf-ptrace.o fork-child.o corelow.o \
hppa-linux-nat.o proc-service.o linux-thread-db.o linux-nat.o \
linux-fork.o
+NAT_CDEPS = $(srcdir)/proc-service.list

-LOADLIBES = -ldl -rdynamic
+LOADLIBES = -ldl -Wl,--dynamic-list=$(srcdir)/proc-service.list
--- a/gdb/config/powerpc/linux.mh
+++ b/gdb/config/powerpc/linux.mh
@@ -6,5 +6,6 @@ NAT_FILE= config/nm-linux.h
NATDEPFILES= inf-ptrace.o fork-child.o \
ppc-linux-nat.o proc-service.o linux-thread-db.o \
linux-nat.o linux-fork.o
+NAT_CDEPS = $(srcdir)/proc-service.list

-LOADLIBES = -ldl -rdynamic
+LOADLIBES = -ldl -Wl,--dynamic-list=$(srcdir)/proc-service.list
--- a/gdb/config/powerpc/ppc64-linux.mh
+++ b/gdb/config/powerpc/ppc64-linux.mh
@@ -6,6 +6,7 @@ NAT_FILE= config/nm-linux.h
NATDEPFILES= inf-ptrace.o fork-child.o \
ppc-linux-nat.o proc-service.o linux-thread-db.o \
linux-nat.o linux-fork.o
+NAT_CDEPS = $(srcdir)/proc-service.list

# The PowerPC has severe limitations on TOC size, and uses them even
# for non-PIC code. GDB overflows those tables when compiling with
@@ -15,4 +16,4 @@ MH_CFLAGS= -mminimal-toc

# The dynamically loaded libthread_db needs access to symbols in the
# gdb executable.
-LOADLIBES= -ldl -rdynamic
+LOADLIBES= -ldl -Wl,--dynamic-list=$(srcdir)/proc-service.list
--- a/gdb/config/s390/s390.mh
+++ b/gdb/config/s390/s390.mh
@@ -2,4 +2,5 @@
NAT_FILE= config/nm-linux.h
NATDEPFILES= inf-ptrace.o fork-child.o corelow.o s390-nat.o \
linux-thread-db.o proc-service.o linux-nat.o linux-fork.o
-LOADLIBES = -ldl -rdynamic
+NAT_CDEPS = $(srcdir)/proc-service.list
+LOADLIBES = -ldl -Wl,--dynamic-list=$(srcdir)/proc-service.list
--- a/gdb/config/sparc/linux.mh
+++ b/gdb/config/sparc/linux.mh
@@ -4,7 +4,8 @@ NATDEPFILES= sparc-nat.o sparc-linux-nat.o \
corelow.o core-regset.o fork-child.o inf-ptrace.o \
proc-service.o linux-thread-db.o \
linux-nat.o linux-fork.o
+NAT_CDEPS = $(srcdir)/proc-service.list

# The dynamically loaded libthread_db needs access to symbols in the
# gdb executable.
-LOADLIBES = -ldl -rdynamic
+LOADLIBES = -ldl -Wl,--dynamic-list=$(srcdir)/proc-service.list
--- a/gdb/config/sparc/linux64.mh
+++ b/gdb/config/sparc/linux64.mh
@@ -5,7 +5,8 @@ NATDEPFILES= sparc-nat.o sparc64-nat.o sparc64-linux-nat.o \
fork-child.o inf-ptrace.o \
proc-service.o linux-thread-db.o \
linux-nat.o linux-fork.o
+NAT_CDEPS = $(srcdir)/proc-service.list

# The dynamically loaded libthread_db needs access to symbols in the
# gdb executable.
-LOADLIBES = -ldl -rdynamic
+LOADLIBES = -ldl -Wl,--dynamic-list=$(srcdir)/proc-service.list
--- a/gdb/config/xtensa/linux.mh
+++ b/gdb/config/xtensa/linux.mh
@@ -4,5 +4,6 @@ NAT_FILE= config/nm-linux.h

NATDEPFILES= inf-ptrace.o fork-child.o xtensa-linux-nat.o \
linux-thread-db.o proc-service.o linux-nat.o linux-fork.o
+NAT_CDEPS = $(srcdir)/proc-service.list

-LOADLIBES = -ldl -rdynamic
+LOADLIBES = -ldl -Wl,--dynamic-list=$(srcdir)/proc-service.list
--- a/gdb/gdbserver/Makefile.in
+++ b/gdb/gdbserver/Makefile.in
@@ -95,12 +95,13 @@ INTERNAL_CFLAGS = $(WARN_CFLAGS) ${CFLAGS} ${GLOBAL_CFLAGS} \
# LDFLAGS is specifically reserved for setting from the command line
# when running make.
LDFLAGS = @LDFLAGS@
-INTERNAL_LDFLAGS = $(LDFLAGS) @RDYNAMIC@
+INTERNAL_LDFLAGS = $(LDFLAGS) @DYNAMIC_LIST@

# All source files that go into linking GDB remote server.

SFILES= $(srcdir)/gdbreplay.c $(srcdir)/inferiors.c \
- $(srcdir)/mem-break.c $(srcdir)/proc-service.c $(srcdir)/regcache.c \
+ $(srcdir)/mem-break.c $(srcdir)/proc-service.c \
+ $(srcdir)/proc-service.list $(srcdir)/regcache.c \
$(srcdir)/remote-utils.c $(srcdir)/server.c $(srcdir)/target.c \
$(srcdir)/thread-db.c $(srcdir)/utils.c \
$(srcdir)/linux-arm-low.c $(srcdir)/linux-cris-low.c \
@@ -133,6 +134,7 @@ OBS = inferiors.o regcache.o remote-utils.o server.o signals.o target.o \
GDBREPLAY_OBS = gdbreplay.o version.o
GDBSERVER_LIBS = @GDBSERVER_LIBS@
XM_CLIBS = @LIBS@
+CDEPS = $(srcdir)/proc-service.list

# XML files to compile in to gdbserver, if any.
XML_DIR = $(srcdir)/../features
--- a/gdb/gdbserver/configure.ac
+++ b/gdb/gdbserver/configure.ac
@@ -189,9 +189,12 @@ if test "$srv_linux_thread_db" = "yes"; then
if test "$ac_cv_lib_dl_dlopen" = "yes"; then
srv_libs="-ldl"
old_LDFLAGS="$LDFLAGS"
- LDFLAGS="$LDFLAGS -rdynamic"
- AC_TRY_LINK([], [], [RDYNAMIC=-rdynamic], [RDYNAMIC=])
- AC_SUBST(RDYNAMIC)
+ DYNAMIC_LIST="-Wl,--dynamic-list=${srcdir}/proc-service.list"
+ LDFLAGS="$LDFLAGS $DYNAMIC_LIST"
+ AC_TRY_LINK([], [],
+ [DYNAMIC_LIST='-Wl,--dynamic-list=$(srcdir)/proc-service.list'],
+ [DYNAMIC_LIST=])
+ AC_SUBST(DYNAMIC_LIST)
LDFLAGS="$old_LDFLAGS"
else
srv_libs="-lthread_db"
--- /dev/null
+++ b/gdb/gdbserver/proc-service.list
@@ -0,0 +1,30 @@
+/* -Wl,--dynamic-list symbols exported for libthread_db.
+
+ Copyright (C) 2010 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/>. */
+
+{
+ ps_get_thread_area;
+ ps_getpid;
+ ps_lgetfpregs;
+ ps_lgetregs;
+ ps_lsetfpregs;
+ ps_lsetregs;
+ ps_pdread;
+ ps_pdwrite;
+ ps_pglobal_lookup;
+};
--- /dev/null
+++ b/gdb/proc-service.list
@@ -0,0 +1,40 @@
+/* -Wl,--dynamic-list symbols exported for libthread_db.
+
+ Copyright (C) 2010 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/>. */
+
+{
+ ps_get_thread_area;
+ ps_getpid;
+ ps_lcontinue;
+ ps_lgetfpregs;
+ ps_lgetregs;
+ ps_lgetxregs;
+ ps_lgetxregsize;
+ ps_lsetfpregs;
+ ps_lsetregs;
+ ps_lsetxregs;
+ ps_lstop;
+ ps_pcontinue;
+ ps_pdread;
+ ps_pdwrite;
+ ps_pglobal_lookup;
+ ps_plog;
+ ps_pstop;
+ ps_ptread;
+ ps_ptwrite;
+};