diff options
author | nobody <> | 2004-03-26 23:15:41 +0000 |
---|---|---|
committer | nobody <> | 2004-03-26 23:15:41 +0000 |
commit | 28d8533826ad7d42113d69618d02f08333ed44ec (patch) | |
tree | fc7bd29d5995347d8ddd0595f2fba2f021c0f40c | |
parent | 58d880d7dc46ef22215df77fa468d76cad99a900 (diff) |
This commit was manufactured by cvs2svn to create tag 'drow_intercu-drow_intercu-merge-20040327
merge-20040327'.
Sprout from ezannoni_pie-20040323-branch 2004-03-23 23:05:53 UTC nobody 'This commit was manufactured by cvs2svn to create branch'
Cherrypick from master 2004-03-26 23:15:40 UTC Joel Brobecker <brobecker@gnat.com> ' * amd64-tdep.c (amd64_classify): make RANGE_TYPE objects be part':
ChangeLog
MAINTAINERS
Makefile.in
Makefile.tpl
bfd/ChangeLog
bfd/bfd-in.h
bfd/bfd-in2.h
bfd/elf-bfd.h
bfd/elf-hppa.h
bfd/elf-m10300.c
bfd/elf32-arm.h
bfd/elf32-cris.c
bfd/elf32-frv.c
bfd/elf32-gen.c
bfd/elf32-hppa.c
bfd/elf32-i370.c
bfd/elf32-i386.c
bfd/elf32-m32r.c
bfd/elf32-m68hc1x.c
bfd/elf32-m68hc1x.h
bfd/elf32-m68k.c
bfd/elf32-ppc.c
bfd/elf32-s390.c
bfd/elf32-sh.c
bfd/elf32-sh64.c
bfd/elf32-sparc.c
bfd/elf32-v850.c
bfd/elf32-vax.c
bfd/elf32-xtensa.c
bfd/elf64-alpha.c
bfd/elf64-gen.c
bfd/elf64-hppa.c
bfd/elf64-mmix.c
bfd/elf64-ppc.c
bfd/elf64-s390.c
bfd/elf64-sh64.c
bfd/elf64-sparc.c
bfd/elf64-x86-64.c
bfd/elfcode.h
bfd/elflink.c
bfd/elflink.h
bfd/elfxx-ia64.c
bfd/elfxx-mips.c
bfd/elfxx-mips.h
bfd/elfxx-target.h
bfd/version.h
configure
configure.in
gdb/ChangeLog
gdb/Makefile.in
gdb/PROBLEMS
gdb/amd64-tdep.c
gdb/arm-linux-tdep.c
gdb/arm-tdep.c
gdb/arm-tdep.h
gdb/armnbsd-tdep.c
gdb/doc/ChangeLog
gdb/doc/gdb.texinfo
gdb/mips-linux-tdep.c
gdb/mips-tdep.c
gdb/ppc-linux-tdep.c
gdb/remote-rdp.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/gdb1250.exp
gdb/testsuite/lib/gdb.exp
gdb/trad-frame.h
gdb/tramp-frame.c
gdb/tramp-frame.h
gdb/version.in
include/ChangeLog
src-release
Delete:
bfd/mpw-config.in
bfd/mpw-make.sed
include/mpw/ChangeLog
include/mpw/README
include/mpw/dir.h
include/mpw/dirent.h
include/mpw/fcntl.h
include/mpw/grp.h
include/mpw/mpw.h
include/mpw/pwd.h
include/mpw/spin.h
include/mpw/stat.h
include/mpw/sys/file.h
include/mpw/sys/param.h
include/mpw/sys/resource.h
include/mpw/sys/stat.h
include/mpw/sys/time.h
include/mpw/sys/types.h
include/mpw/utime.h
include/mpw/varargs.h
mpw-README
mpw-build.in
mpw-config.in
mpw-configure
mpw-install
96 files changed, 3408 insertions, 4904 deletions
diff --git a/ChangeLog b/ChangeLog index 56ba3dc4e75..76cea3506d7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,35 @@ +2004-03-25 Stan Shebs <shebs@apple.com> + + Remove MPW support, no longer used. + * mpw-README, mpw-build.in, mpw-config.in, mpw-configure, + mpw-install: Remove files. + * src-release (DEVO_SUPPORT): Remove names of removed files. + * MAINTAINERS: Likewise. + +2004-03-24 Nathanael Nerode <neroden@gcc.gnu.org> + + * Makefile.tpl (top level bootstrap support): Remove now-unneeded + STRICT_WARN, WARN_CFLAGS flags passed down to make. + * Makefile.in: Regenerate. + + * configure.in (top level bootstrap support): Rework --enable-werror + to set @stage2_werror_flag@. + * configure: Regenerate. + * Makefile.tpl (top level bootstrap support): Pass + @stage2_werror_flag@ down to configure in stages 2 and 3. + * Makefile.in: Regenerate. + +2004-03-23 Nathanael Nerode <neroden@gcc.gnu.org> + + * Makefile.tpl (new-bootstrap): Set CC and CC_FOR_BUILD in configure + for stages 2 and 3 as well as in make. As a consequence, remove + OUTPUT_OPTION (now detected by configure) from the flags passed down + to make. + * Makefile.in: Regenerate. + + * Makefile.tpl (new-bootstrap): Fix typo. + * Makefile.in: Regenerate. + 2004-03-22 Nathanael Nerode <neroden@gcc.gnu.org> * Makefile.tpl: Rearrange by moving recursive_targets rules diff --git a/MAINTAINERS b/MAINTAINERS index c9ad6b30f87..71942684b28 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -100,8 +100,7 @@ winsup/ General discussion cygwin@sources.redhat.com. See also winsup/MAINTAINERS. -expect/; config-ml.in; mpw-README; mpw-build.in; mpw-config.in; -mpw-configure; mpw-install; setup.com; missing; makefile.vms; utils/; +expect/; config-ml.in; setup.com; missing; makefile.vms; utils/; config/; config.if; makefile.vms; missing; ylwrap; mkdep; etc/; install-sh; intl/ Ask DJ Delorie <dj@redhat.com> after reading the libiberty entry. diff --git a/Makefile.in b/Makefile.in index 68f43e6acb0..593566086b5 100644 --- a/Makefile.in +++ b/Makefile.in @@ -24046,6 +24046,8 @@ all-stage1-gcc: configure-stage1-gcc prebootstrap $(STAMP) all-stage1-gcc # TODO: Deal with STAGE_PREFIX (which is only for ada, incidentally) +# Possibly pass --enable-werror-always (depending on --enable-werror); +# that's what @stage2_werror_flag@ is for configure-stage2-gcc: all-stage1-gcc echo configure-stage2-gcc > stage_last ; \ if [ -f stage2-gcc/Makefile ] ; then \ @@ -24061,13 +24063,11 @@ configure-stage2-gcc: all-stage1-gcc s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \ TOPLEVEL_CONFIGURE_ARGUMENTS="$(TOPLEVEL_CONFIGURE_ARGUMENTS)"; export TOPLEVEL_CONFIGURE_ARGUMENTS; \ - CC="$(CC)"; export CC; \ CFLAGS="$(CFLAGS)"; export CFLAGS; \ CXX="$(CXX)"; export CXX; \ CXXFLAGS="$(CXXFLAGS)"; export CXXFLAGS; \ AR="$(AR)"; export AR; \ AS="$(AS)"; export AS; \ - CC_FOR_BUILD="$(CC_FOR_BUILD)"; export CC_FOR_BUILD; \ DLLTOOL="$(DLLTOOL)"; export DLLTOOL; \ LD="$(LD)"; export LD; \ NM="$(NM)"; export NM; \ @@ -24075,6 +24075,8 @@ configure-stage2-gcc: all-stage1-gcc WINDRES="$(WINDRES)"; export WINDRES; \ OBJCOPY="$(OBJCOPY)"; export OBJCOPY; \ OBJDUMP="$(OBJDUMP)"; export OBJDUMP; \ + CC="$(STAGE_CC_WRAPPER) $$r/prev-gcc/xgcc$(exeext) -B$$r/prev-gcc/ -B$(build_tooldir)/bin/"; export CC; \ + CC_FOR_BUILD="$(STAGE_CC_WRAPPER) $$r/prev-gcc/xgcc$(exeext) -B$$r/prev-gcc/ -B$(build_tooldir)/bin/"; export CC_FOR_BUILD; \ echo Configuring stage 2 in gcc; \ cd gcc || exit 1; \ case $(srcdir) in \ @@ -24089,7 +24091,7 @@ configure-stage2-gcc: all-stage1-gcc libsrcdir="$$s/gcc";; \ esac; \ $(SHELL) $${libsrcdir}/configure \ - $(HOST_CONFIGARGS) $${srcdiroption} ; \ + $(HOST_CONFIGARGS) $${srcdiroption} @stage2_werror_flag@ ; \ cd .. ; \ mv gcc stage2-gcc ; \ mv prev-gcc stage1-gcc ; \ @@ -24099,10 +24101,7 @@ configure-stage2-gcc: all-stage1-gcc BOOT_CFLAGS= -g -O2 POSTSTAGE1_FLAGS_TO_PASS = \ CFLAGS="$(BOOT_CFLAGS)" \ - ADAC="\$$(CC)" \ - WARN_CFLAGS="\$$(GCC_WARN_CFLAGS)" \ - STRICT_WARN="\$$(STRICT2_WARN)" \ - OUTPUT_OPTION="-o \$$@" + ADAC="\$$(CC)" all-stage2-gcc: all-stage1-gcc configure-stage2-gcc echo all-stage2-gcc > stage_last ; \ @@ -24131,18 +24130,16 @@ configure-stage3-gcc: all-stage2-gcc fi ; \ [ -d stage3-gcc ] || mkdir stage3-gcc; \ mv stage3-gcc gcc ; \ - mv stage1-gcc prev-gcc ; \ + mv stage2-gcc prev-gcc ; \ r=`${PWD_COMMAND}`; export r; \ s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \ TOPLEVEL_CONFIGURE_ARGUMENTS="$(TOPLEVEL_CONFIGURE_ARGUMENTS)"; export TOPLEVEL_CONFIGURE_ARGUMENTS; \ - CC="$(CC)"; export CC; \ CFLAGS="$(CFLAGS)"; export CFLAGS; \ CXX="$(CXX)"; export CXX; \ CXXFLAGS="$(CXXFLAGS)"; export CXXFLAGS; \ AR="$(AR)"; export AR; \ AS="$(AS)"; export AS; \ - CC_FOR_BUILD="$(CC_FOR_BUILD)"; export CC_FOR_BUILD; \ DLLTOOL="$(DLLTOOL)"; export DLLTOOL; \ LD="$(LD)"; export LD; \ NM="$(NM)"; export NM; \ @@ -24150,6 +24147,8 @@ configure-stage3-gcc: all-stage2-gcc WINDRES="$(WINDRES)"; export WINDRES; \ OBJCOPY="$(OBJCOPY)"; export OBJCOPY; \ OBJDUMP="$(OBJDUMP)"; export OBJDUMP; \ + CC="$(STAGE_CC_WRAPPER) $$r/prev-gcc/xgcc$(exeext) -B$$r/prev-gcc/ -B$(build_tooldir)/bin/"; export CC; \ + CC_FOR_BUILD="$(STAGE_CC_WRAPPER) $$r/prev-gcc/xgcc$(exeext) -B$$r/prev-gcc/ -B$(build_tooldir)/bin/"; export CC_FOR_BUILD; \ echo Configuring stage 3 in gcc; \ cd gcc || exit 1; \ case $(srcdir) in \ @@ -24164,7 +24163,7 @@ configure-stage3-gcc: all-stage2-gcc libsrcdir="$$s/gcc";; \ esac; \ $(SHELL) $${libsrcdir}/configure \ - $(HOST_CONFIGARGS) $${srcdiroption} ; \ + $(HOST_CONFIGARGS) $${srcdiroption} @stage2_werror_flag@ ; \ cd .. ; \ mv gcc stage3-gcc ; \ mv prev-gcc stage2-gcc ; \ diff --git a/Makefile.tpl b/Makefile.tpl index 91fdae2d285..cd7e06eccdc 100644 --- a/Makefile.tpl +++ b/Makefile.tpl @@ -1374,6 +1374,8 @@ all-stage1-gcc: configure-stage1-gcc prebootstrap $(STAMP) all-stage1-gcc # TODO: Deal with STAGE_PREFIX (which is only for ada, incidentally) +# Possibly pass --enable-werror-always (depending on --enable-werror); +# that's what @stage2_werror_flag@ is for configure-stage2-gcc: all-stage1-gcc echo configure-stage2-gcc > stage_last ; \ if [ -f stage2-gcc/Makefile ] ; then \ @@ -1389,13 +1391,11 @@ configure-stage2-gcc: all-stage1-gcc s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \ TOPLEVEL_CONFIGURE_ARGUMENTS="$(TOPLEVEL_CONFIGURE_ARGUMENTS)"; export TOPLEVEL_CONFIGURE_ARGUMENTS; \ - CC="$(CC)"; export CC; \ CFLAGS="$(CFLAGS)"; export CFLAGS; \ CXX="$(CXX)"; export CXX; \ CXXFLAGS="$(CXXFLAGS)"; export CXXFLAGS; \ AR="$(AR)"; export AR; \ AS="$(AS)"; export AS; \ - CC_FOR_BUILD="$(CC_FOR_BUILD)"; export CC_FOR_BUILD; \ DLLTOOL="$(DLLTOOL)"; export DLLTOOL; \ LD="$(LD)"; export LD; \ NM="$(NM)"; export NM; \ @@ -1403,6 +1403,8 @@ configure-stage2-gcc: all-stage1-gcc WINDRES="$(WINDRES)"; export WINDRES; \ OBJCOPY="$(OBJCOPY)"; export OBJCOPY; \ OBJDUMP="$(OBJDUMP)"; export OBJDUMP; \ + CC="$(STAGE_CC_WRAPPER) $$r/prev-gcc/xgcc$(exeext) -B$$r/prev-gcc/ -B$(build_tooldir)/bin/"; export CC; \ + CC_FOR_BUILD="$(STAGE_CC_WRAPPER) $$r/prev-gcc/xgcc$(exeext) -B$$r/prev-gcc/ -B$(build_tooldir)/bin/"; export CC_FOR_BUILD; \ echo Configuring stage 2 in gcc; \ cd gcc || exit 1; \ case $(srcdir) in \ @@ -1417,7 +1419,7 @@ configure-stage2-gcc: all-stage1-gcc libsrcdir="$$s/gcc";; \ esac; \ $(SHELL) $${libsrcdir}/configure \ - $(HOST_CONFIGARGS) $${srcdiroption} ; \ + $(HOST_CONFIGARGS) $${srcdiroption} @stage2_werror_flag@ ; \ cd .. ; \ mv gcc stage2-gcc ; \ mv prev-gcc stage1-gcc ; \ @@ -1427,10 +1429,7 @@ configure-stage2-gcc: all-stage1-gcc BOOT_CFLAGS= -g -O2 POSTSTAGE1_FLAGS_TO_PASS = \ CFLAGS="$(BOOT_CFLAGS)" \ - ADAC="\$$(CC)" \ - WARN_CFLAGS="\$$(GCC_WARN_CFLAGS)" \ - STRICT_WARN="\$$(STRICT2_WARN)" \ - OUTPUT_OPTION="-o \$$@" + ADAC="\$$(CC)" all-stage2-gcc: all-stage1-gcc configure-stage2-gcc echo all-stage2-gcc > stage_last ; \ @@ -1459,18 +1458,16 @@ configure-stage3-gcc: all-stage2-gcc fi ; \ [ -d stage3-gcc ] || mkdir stage3-gcc; \ mv stage3-gcc gcc ; \ - mv stage1-gcc prev-gcc ; \ + mv stage2-gcc prev-gcc ; \ r=`${PWD_COMMAND}`; export r; \ s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \ CONFIG_SHELL="$(SHELL)"; export CONFIG_SHELL; \ TOPLEVEL_CONFIGURE_ARGUMENTS="$(TOPLEVEL_CONFIGURE_ARGUMENTS)"; export TOPLEVEL_CONFIGURE_ARGUMENTS; \ - CC="$(CC)"; export CC; \ CFLAGS="$(CFLAGS)"; export CFLAGS; \ CXX="$(CXX)"; export CXX; \ CXXFLAGS="$(CXXFLAGS)"; export CXXFLAGS; \ AR="$(AR)"; export AR; \ AS="$(AS)"; export AS; \ - CC_FOR_BUILD="$(CC_FOR_BUILD)"; export CC_FOR_BUILD; \ DLLTOOL="$(DLLTOOL)"; export DLLTOOL; \ LD="$(LD)"; export LD; \ NM="$(NM)"; export NM; \ @@ -1478,6 +1475,8 @@ configure-stage3-gcc: all-stage2-gcc WINDRES="$(WINDRES)"; export WINDRES; \ OBJCOPY="$(OBJCOPY)"; export OBJCOPY; \ OBJDUMP="$(OBJDUMP)"; export OBJDUMP; \ + CC="$(STAGE_CC_WRAPPER) $$r/prev-gcc/xgcc$(exeext) -B$$r/prev-gcc/ -B$(build_tooldir)/bin/"; export CC; \ + CC_FOR_BUILD="$(STAGE_CC_WRAPPER) $$r/prev-gcc/xgcc$(exeext) -B$$r/prev-gcc/ -B$(build_tooldir)/bin/"; export CC_FOR_BUILD; \ echo Configuring stage 3 in gcc; \ cd gcc || exit 1; \ case $(srcdir) in \ @@ -1492,7 +1491,7 @@ configure-stage3-gcc: all-stage2-gcc libsrcdir="$$s/gcc";; \ esac; \ $(SHELL) $${libsrcdir}/configure \ - $(HOST_CONFIGARGS) $${srcdiroption} ; \ + $(HOST_CONFIGARGS) $${srcdiroption} @stage2_werror_flag@ ; \ cd .. ; \ mv gcc stage3-gcc ; \ mv prev-gcc stage2-gcc ; \ diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 6560ebc5d1b..0b8b69cb016 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,105 @@ +2004-03-26 Alan Modra <amodra@bigpond.net.au> + + * elf64-ppc.c (elf_backend_add_symbol_hook): Define. + (ppc64_elf_add_symbol_hook): New function. + * elf-bfd.h (struct elf_backend_data <elf_add_symbol_hook>): Remove + const from Elf_Internal_Sym param. + * elflink.c (elf_link_add_object_symbols): Adjust. + * elf-hppa.h (elf_hppa_add_symbol_hook): Adjust. + * elf32-frv.c (elf32_frv_add_symbol_hook): Adjust. + * elf32-i370.c (elf_backend_add_symbol_hook): Adjust. + * elf32-m32r.c (m32r_elf_add_symbol_hook): Adjust. + * elf32-m68hc1x.c (elf32_m68hc11_add_symbol_hook): Adjust. + * elf32-m68hc1x.h (elf32_m68hc11_add_symbol_hook): Adjust. + * elf32-ppc.c (ppc_elf_add_symbol_hook): Adjust. + * elf32-sh64.c (sh64_elf_add_symbol_hook): Adjust. + * elf32-v850.c (v850_elf_add_symbol_hook): Adjust. + * elf64-alpha.c (elf64_alpha_add_symbol_hook): Adjust. + * elf64-mmix.c (mmix_elf_add_symbol_hook): Adjust. + * elf64-sh64.c (sh64_elf64_add_symbol_hook): Adjust. + * elf64-sparc.c (sparc64_elf_add_symbol_hook): Adjust. + * elfxx-ia64.c (elfNN_ia64_add_symbol_hook): Adjust. + * elfxx-mips.c (_bfd_mips_elf_add_symbol_hook): Adjust. + * elfxx-mips.h (_bfd_mips_elf_add_symbol_hook): Adjust. + +2004-03-26 Alan Modra <amodra@bigpond.net.au> + + * elfxx-target.h (bfd_elfNN_bfd_link_add_symbols): Define. + * elf-bfd.h (_bfd_elf_link_add_archive_symbols): Delete. + (_bfd_elf_sort_symbol, _bfd_elf_add_dt_needed_tag): Delete. + (_bfd_elf_finalize_dynstr, bfd_elf32_bfd_link_add_symbols): Delete. + (bfd_elf64_bfd_link_add_symbols): Delete. + (bfd_elf_link_add_symbols): Declare. + * elfcode.h (elf_bfd_link_add_symbols): Delete. + * elflink.c: Include safe-ctype.h. + (elf_add_dt_needed_tag): Rename from _bfd_elf_add_dt_needed_tag, + make static. + (elf_sort_symbol): Rename from _bfd_elf_sort_symbol, make static. + (elf_finalize_dynstr): Rename from _bfd_elf_finalize_dynstr, make + static. + (elf_link_add_archive_symbols): Rename from + _bfd_elf_link_add_archive_symbols, make static. + (elf_link_add_object_symbols): New function. Corresponding + elflink.h function converted to use elf_size_info. + (bfd_elf_link_add_symbols): Likewise. + (bfd_elf_size_dynamic_sections): Adjust. + * elflink.h (elf_bfd_link_add_symbols): Delete. + (elf_link_add_object_symbols): Delete. + * elf32-gen.c (elf32_generic_link_add_symbols): Call + bfd_elf_link_add_symbols. + * elf64-gen.c (elf64_generic_link_add_symbols): Likewise. + +2004-03-25 Alan Modra <amodra@bigpond.net.au> + + * elflink.h (elf_link_add_object_symbols): Add DT_NEEDED for as-needed + and chained shared libs only if dynsym. Clear dynsym on forced-local. + + * elf-bfd.h (_bfd_elf_add_dynamic_entry): Declare. + (bfd_elf32_add_dynamic_entry, bfd_elf64_add_dynamic_entry): Delete. + (_bfd_elf_add_dt_needed_tag): Declare. + (_bfd_elf_sort_symbol): Declare. + (_bfd_elf_finalize_dynstr): Declare. + (RELOC_FOR_GLOBAL_SYM): Formatting. + * elfcode.h (elf_add_dynamic_entry): Delete. + * elflink.c (_bfd_elf_add_dynamic_entry): New function. Corresponding + elflink.h function converted to use elf_size_info. + (_bfd_elf_add_dt_needed_tag): Likewise. + (_bfd_elf_sort_symbol): Likewise. + (_bfd_elf_finalize_dynstr): Likewise. + (compute_bucket_count): Likewise. + (bfd_elf_size_dynamic_sections): Likewise. Check result of + _bfd_elf_strtab_add before calling _bfd_elf_strtab_addref. + (elf_adjust_dynstr_offsets, elf_collect_hash_codes): Moved from.. + * elflink.h: ..here. + (sort_symbol, add_dt_needed_tag): Delete. + (elf_add_dynamic_entry, elf_finalize_dynstr): Delete. + (compute_bucket_count, NAME(bfd_elf,size_dynamic_sections)): Delete. + Update all users. + * elf32-arm.h (add_dynamic_entry): Update. Remove casts. + * elf32-cris.c (add_dynamic_entry): Likewise. + * elf32-hppa.c (add_dynamic_entry): Likewise. + * elf32-i370.c (add_dynamic_entry): Likewise. + * elf32-i386.c (add_dynamic_entry): Likewise. + * elf32-m32r.c (add_dynamic_entry): Likewise. + * elf32-m68k.c (add_dynamic_entry): Likewise. + * elf32-ppc.c (add_dynamic_entry): Likewise. + * elf32-s390.c (add_dynamic_entry): Likewise. + * elf32-sh.c (add_dynamic_entry): Likewise. + * elf32-sparc.c (add_dynamic_entry): Likewise. + * elf32-vax.c (add_dynamic_entry): Likewise. + * elf32-xtensa.c (add_dynamic_entry): Likewise. + * elf64-alpha.c (add_dynamic_entry): Likewise. + * elf64-hppa.c (add_dynamic_entry): Likewise. + * elf64-ppc.c (add_dynamic_entry): Likewise. + * elf64-s390.c (add_dynamic_entry): Likewise. + * elf64-sparc.c (add_dynamic_entry): Likewise. + * elf64-x86-64.c (add_dynamic_entry): Likewise. + * elfxx-ia64.c (add_dynamic_entry): Likewise. + * elfxx-mips.c (MIPS_ELF_ADD_DYNAMIC_ENTRY): Likewise. + * elf-m10300.c (_bfd_mn10300_elf_size_dynamic_sections): Likewise. + * elf32-frv.c (elf32_frv_size_dynamic_sections): Likewise. + * elf64-sh64.c (sh64_elf64_size_dynamic_sections): Likewise. + 2004-03-23 Paul Brook <paul@codesourcery.com> * elf32-arm.h (arm_print_private_bfd_data): Add EABI v3. diff --git a/bfd/bfd-in.h b/bfd/bfd-in.h index fedcb372b32..ff585fde0ef 100644 --- a/bfd/bfd-in.h +++ b/bfd/bfd-in.h @@ -611,10 +611,7 @@ extern struct bfd_link_needed_list *bfd_elf_get_needed_list (bfd *, struct bfd_link_info *); extern bfd_boolean bfd_elf_get_bfd_needed_list (bfd *, struct bfd_link_needed_list **); -extern bfd_boolean bfd_elf32_size_dynamic_sections - (bfd *, const char *, const char *, const char *, const char * const *, - struct bfd_link_info *, struct bfd_section **, struct bfd_elf_version_tree *); -extern bfd_boolean bfd_elf64_size_dynamic_sections +extern bfd_boolean bfd_elf_size_dynamic_sections (bfd *, const char *, const char *, const char *, const char * const *, struct bfd_link_info *, struct bfd_section **, struct bfd_elf_version_tree *); extern void bfd_elf_set_dt_needed_name diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h index 5e53956477e..060dcc6bef9 100644 --- a/bfd/bfd-in2.h +++ b/bfd/bfd-in2.h @@ -618,10 +618,7 @@ extern struct bfd_link_needed_list *bfd_elf_get_needed_list (bfd *, struct bfd_link_info *); extern bfd_boolean bfd_elf_get_bfd_needed_list (bfd *, struct bfd_link_needed_list **); -extern bfd_boolean bfd_elf32_size_dynamic_sections - (bfd *, const char *, const char *, const char *, const char * const *, - struct bfd_link_info *, struct bfd_section **, struct bfd_elf_version_tree *); -extern bfd_boolean bfd_elf64_size_dynamic_sections +extern bfd_boolean bfd_elf_size_dynamic_sections (bfd *, const char *, const char *, const char *, const char * const *, struct bfd_link_info *, struct bfd_section **, struct bfd_elf_version_tree *); extern void bfd_elf_set_dt_needed_name diff --git a/bfd/elf-bfd.h b/bfd/elf-bfd.h index cd51e3265bb..484a4923e15 100644 --- a/bfd/elf-bfd.h +++ b/bfd/elf-bfd.h @@ -625,7 +625,7 @@ struct elf_backend_data indices, and must set at least *FLAGS and *SEC for each processor dependent case; failure to do so will cause a link error. */ bfd_boolean (*elf_add_symbol_hook) - (bfd *abfd, struct bfd_link_info *info, const Elf_Internal_Sym *, + (bfd *abfd, struct bfd_link_info *info, Elf_Internal_Sym *, const char **name, flagword *flags, asection **sec, bfd_vma *value); /* If this field is not NULL, it is called by the elf_link_output_sym @@ -1544,9 +1544,6 @@ extern bfd_boolean _bfd_elf_dynamic_symbol_p extern bfd_boolean _bfd_elf_symbol_refs_local_p (struct elf_link_hash_entry *, struct bfd_link_info *, bfd_boolean); -extern bfd_boolean _bfd_elf_link_add_archive_symbols - (bfd *, struct bfd_link_info *); - extern const bfd_target *bfd_elf32_object_p (bfd *); extern const bfd_target *bfd_elf32_core_file_p @@ -1558,8 +1555,6 @@ extern int bfd_elf32_core_file_failing_signal extern bfd_boolean bfd_elf32_core_file_matches_executable_p (bfd *, bfd *); -extern bfd_boolean bfd_elf32_bfd_link_add_symbols - (bfd *, struct bfd_link_info *); extern bfd_boolean bfd_elf32_bfd_final_link (bfd *, struct bfd_link_info *); @@ -1593,8 +1588,6 @@ extern void bfd_elf32_write_relocs (bfd *, asection *, void *); extern bfd_boolean bfd_elf32_slurp_reloc_table (bfd *, asection *, asymbol **, bfd_boolean); -extern bfd_boolean bfd_elf32_add_dynamic_entry - (struct bfd_link_info *, bfd_vma, bfd_vma); extern const bfd_target *bfd_elf64_object_p (bfd *); @@ -1606,8 +1599,6 @@ extern int bfd_elf64_core_file_failing_signal (bfd *); extern bfd_boolean bfd_elf64_core_file_matches_executable_p (bfd *, bfd *); -extern bfd_boolean bfd_elf64_bfd_link_add_symbols - (bfd *, struct bfd_link_info *); extern bfd_boolean bfd_elf64_bfd_final_link (bfd *, struct bfd_link_info *); @@ -1641,7 +1632,10 @@ extern void bfd_elf64_write_relocs (bfd *, asection *, void *); extern bfd_boolean bfd_elf64_slurp_reloc_table (bfd *, asection *, asymbol **, bfd_boolean); -extern bfd_boolean bfd_elf64_add_dynamic_entry + +extern bfd_boolean bfd_elf_link_add_symbols + (bfd *, struct bfd_link_info *); +extern bfd_boolean _bfd_elf_add_dynamic_entry (struct bfd_link_info *, bfd_vma, bfd_vma); #define bfd_elf32_link_record_dynamic_symbol \ @@ -1762,12 +1756,14 @@ extern bfd_boolean _sh_elf_set_mach_from_flags ; \ else \ { \ - if (! info->callbacks->undefined_symbol \ - (info, h->root.root.string, input_bfd, \ - input_section, rel->r_offset, \ - (info->unresolved_syms_in_objects == RM_GENERATE_ERROR \ - || ELF_ST_VISIBILITY (h->other)) \ - )) \ + bfd_boolean err; \ + err = (info->unresolved_syms_in_objects == RM_GENERATE_ERROR \ + || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT); \ + if (!info->callbacks->undefined_symbol (info, \ + h->root.root.string, \ + input_bfd, \ + input_section, \ + rel->r_offset, err)) \ return FALSE; \ warned = TRUE; \ } \ diff --git a/bfd/elf-hppa.h b/bfd/elf-hppa.h index f5aba51e55f..534dd11453a 100644 --- a/bfd/elf-hppa.h +++ b/bfd/elf-hppa.h @@ -1,5 +1,6 @@ /* Common code for PA ELF implementations. - Copyright 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. + Copyright 1999, 2000, 2001, 2002, 2003, 2004 + Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -1070,7 +1071,7 @@ static bfd_boolean elf_hppa_sort_unwind (bfd *abfd) static bfd_boolean elf_hppa_add_symbol_hook (bfd *abfd, struct bfd_link_info *info ATTRIBUTE_UNUSED, - const Elf_Internal_Sym *sym, + Elf_Internal_Sym *sym, const char **namep ATTRIBUTE_UNUSED, flagword *flagsp ATTRIBUTE_UNUSED, asection **secp, diff --git a/bfd/elf-m10300.c b/bfd/elf-m10300.c index a1327944e6b..8277bae301c 100644 --- a/bfd/elf-m10300.c +++ b/bfd/elf-m10300.c @@ -4491,31 +4491,31 @@ _bfd_mn10300_elf_size_dynamic_sections (output_bfd, info) in by the dynamic linker and used by the debugger. */ if (! info->shared) { - if (! bfd_elf32_add_dynamic_entry (info, DT_DEBUG, 0)) + if (!_bfd_elf_add_dynamic_entry (info, DT_DEBUG, 0)) return FALSE; } if (plt) { - if (! bfd_elf32_add_dynamic_entry (info, DT_PLTGOT, 0) - || ! bfd_elf32_add_dynamic_entry (info, DT_PLTRELSZ, 0) - || ! bfd_elf32_add_dynamic_entry (info, DT_PLTREL, DT_RELA) - || ! bfd_elf32_add_dynamic_entry (info, DT_JMPREL, 0)) + if (!_bfd_elf_add_dynamic_entry (info, DT_PLTGOT, 0) + || !_bfd_elf_add_dynamic_entry (info, DT_PLTRELSZ, 0) + || !_bfd_elf_add_dynamic_entry (info, DT_PLTREL, DT_RELA) + || !_bfd_elf_add_dynamic_entry (info, DT_JMPREL, 0)) return FALSE; } if (relocs) { - if (! bfd_elf32_add_dynamic_entry (info, DT_RELA, 0) - || ! bfd_elf32_add_dynamic_entry (info, DT_RELASZ, 0) - || ! bfd_elf32_add_dynamic_entry (info, DT_RELAENT, - sizeof (Elf32_External_Rela))) + if (!_bfd_elf_add_dynamic_entry (info, DT_RELA, 0) + || !_bfd_elf_add_dynamic_entry (info, DT_RELASZ, 0) + || !_bfd_elf_add_dynamic_entry (info, DT_RELAENT, + sizeof (Elf32_External_Rela))) return FALSE; } if (reltext) { - if (! bfd_elf32_add_dynamic_entry (info, DT_TEXTREL, 0)) + if (!_bfd_elf_add_dynamic_entry (info, DT_TEXTREL, 0)) return FALSE; } } diff --git a/bfd/elf32-arm.h b/bfd/elf32-arm.h index 33f85bd609a..89540f03d2f 100644 --- a/bfd/elf32-arm.h +++ b/bfd/elf32-arm.h @@ -3665,7 +3665,7 @@ elf32_arm_size_dynamic_sections (output_bfd, info) the .dynamic section. The DT_DEBUG entry is filled in by the dynamic linker and used by the debugger. */ #define add_dynamic_entry(TAG, VAL) \ - bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL)) + _bfd_elf_add_dynamic_entry (info, TAG, VAL) if (!info->shared) { diff --git a/bfd/elf32-cris.c b/bfd/elf32-cris.c index b8513928e42..b405d9e63ba 100644 --- a/bfd/elf32-cris.c +++ b/bfd/elf32-cris.c @@ -2809,7 +2809,7 @@ elf_cris_size_dynamic_sections (output_bfd, info) the .dynamic section. The DT_DEBUG entry is filled in by the dynamic linker and used by the debugger. */ #define add_dynamic_entry(TAG, VAL) \ - bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL)) + _bfd_elf_add_dynamic_entry (info, TAG, VAL) if (!info->shared) { diff --git a/bfd/elf32-frv.c b/bfd/elf32-frv.c index eedc55d6e7d..039b4a3b479 100644 --- a/bfd/elf32-frv.c +++ b/bfd/elf32-frv.c @@ -1,5 +1,5 @@ /* FRV-specific support for 32-bit ELF. - Copyright 2002, 2003 Free Software Foundation, Inc. + Copyright 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -52,7 +52,7 @@ static bfd_boolean elf32_frv_relocate_section PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, Elf_Internal_Rela *, Elf_Internal_Sym *, asection **)); static bfd_boolean elf32_frv_add_symbol_hook - PARAMS (( bfd *, struct bfd_link_info *, const Elf_Internal_Sym *, + PARAMS (( bfd *, struct bfd_link_info *, Elf_Internal_Sym *, const char **, flagword *, asection **, bfd_vma *)); static bfd_reloc_status_type frv_final_link_relocate PARAMS ((reloc_howto_type *, bfd *, asection *, bfd_byte *, @@ -2584,7 +2584,7 @@ static bfd_boolean elf32_frv_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) bfd *abfd; struct bfd_link_info *info; - const Elf_Internal_Sym *sym; + Elf_Internal_Sym *sym; const char **namep ATTRIBUTE_UNUSED; flagword *flagsp ATTRIBUTE_UNUSED; asection **secp; @@ -3536,20 +3536,20 @@ elf32_frv_size_dynamic_sections (bfd *output_bfd, if (elf_hash_table (info)->dynamic_sections_created) { if (frv_got_section (info)->_raw_size) - if (! bfd_elf32_add_dynamic_entry (info, DT_PLTGOT, 0)) + if (!_bfd_elf_add_dynamic_entry (info, DT_PLTGOT, 0)) return FALSE; if (frv_pltrel_section (info)->_raw_size) - if (! bfd_elf32_add_dynamic_entry (info, DT_PLTRELSZ, 0) - || ! bfd_elf32_add_dynamic_entry (info, DT_PLTREL, DT_REL) - || ! bfd_elf32_add_dynamic_entry (info, DT_JMPREL, 0)) + if (!_bfd_elf_add_dynamic_entry (info, DT_PLTRELSZ, 0) + || !_bfd_elf_add_dynamic_entry (info, DT_PLTREL, DT_REL) + || !_bfd_elf_add_dynamic_entry (info, DT_JMPREL, 0)) return FALSE; if (frv_gotrel_section (info)->_raw_size) - if (! bfd_elf32_add_dynamic_entry (info, DT_REL, 0) - || ! bfd_elf32_add_dynamic_entry (info, DT_RELSZ, 0) - || ! bfd_elf32_add_dynamic_entry (info, DT_RELENT, - sizeof (Elf32_External_Rel))) + if (!_bfd_elf_add_dynamic_entry (info, DT_REL, 0) + || !_bfd_elf_add_dynamic_entry (info, DT_RELSZ, 0) + || !_bfd_elf_add_dynamic_entry (info, DT_RELENT, + sizeof (Elf32_External_Rel))) return FALSE; } diff --git a/bfd/elf32-gen.c b/bfd/elf32-gen.c index b1ad74486f4..f2edf69da6b 100644 --- a/bfd/elf32-gen.c +++ b/bfd/elf32-gen.c @@ -1,5 +1,5 @@ /* Generic support for 32-bit ELF - Copyright 1993, 1995, 1998, 1999, 2001, 2002 + Copyright 1993, 1995, 1998, 1999, 2001, 2002, 2004 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -88,7 +88,7 @@ elf32_generic_link_add_symbols (abfd, info) return FALSE; } - return bfd_elf32_bfd_link_add_symbols (abfd, info); + return bfd_elf_link_add_symbols (abfd, info); } #define TARGET_LITTLE_SYM bfd_elf32_little_generic_vec diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c index 63b98e568e3..cffd194c881 100644 --- a/bfd/elf32-hppa.c +++ b/bfd/elf32-hppa.c @@ -2241,7 +2241,7 @@ elf32_hppa_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, communicate the LTP value of a load module to the dynamic linker. */ #define add_dynamic_entry(TAG, VAL) \ - bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL)) + _bfd_elf_add_dynamic_entry (info, TAG, VAL) if (!add_dynamic_entry (DT_PLTGOT, 0)) return FALSE; diff --git a/bfd/elf32-i370.c b/bfd/elf32-i370.c index 57854c88edd..f7829250081 100644 --- a/bfd/elf32-i370.c +++ b/bfd/elf32-i370.c @@ -1,5 +1,5 @@ /* i370-specific support for 32-bit ELF - Copyright 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003 + Copyright 1994, 1995, 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. Written by Ian Lance Taylor, Cygnus Support. Hacked by Linas Vepstas for i370 linas@linas.org @@ -791,7 +791,7 @@ i370_elf_size_dynamic_sections (output_bfd, info) the .dynamic section. The DT_DEBUG entry is filled in by the dynamic linker and used by the debugger. */ #define add_dynamic_entry(TAG, VAL) \ - bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL)) + _bfd_elf_add_dynamic_entry (info, TAG, VAL) if (!info->shared) { @@ -1548,7 +1548,7 @@ static int i370_noop () #define elf_backend_add_symbol_hook \ (bfd_boolean (*) \ - PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *, \ + PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Sym *, \ const char **, flagword *, asection **, bfd_vma *))) i370_noop #define elf_backend_finish_dynamic_symbol \ (bfd_boolean (*) \ diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c index 8f30bb2c231..f1c27d00113 100644 --- a/bfd/elf32-i386.c +++ b/bfd/elf32-i386.c @@ -1895,7 +1895,7 @@ elf_i386_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, the .dynamic section. The DT_DEBUG entry is filled in by the dynamic linker and used by the debugger. */ #define add_dynamic_entry(TAG, VAL) \ - bfd_elf32_add_dynamic_entry (info, (TAG), (VAL)) + _bfd_elf_add_dynamic_entry (info, TAG, VAL) if (info->executable) { diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c index e3c6ffb1ca2..812b3ca0451 100644 --- a/bfd/elf32-m32r.c +++ b/bfd/elf32-m32r.c @@ -51,7 +51,7 @@ bfd_boolean _bfd_m32r_elf_section_from_bfd_section void _bfd_m32r_elf_symbol_processing PARAMS ((bfd *, asymbol *)); static bfd_boolean m32r_elf_add_symbol_hook - PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *, + PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Sym *, const char **, flagword *, asection **, bfd_vma *)); static bfd_boolean m32r_elf_relocate_section PARAMS ((bfd *, struct bfd_link_info *, bfd *, asection *, bfd_byte *, @@ -1391,7 +1391,7 @@ static bfd_boolean m32r_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) bfd *abfd; struct bfd_link_info *info; - const Elf_Internal_Sym *sym; + Elf_Internal_Sym *sym; const char **namep; flagword *flagsp ATTRIBUTE_UNUSED; asection **secp; @@ -2442,7 +2442,7 @@ printf("m32r_elf_size_dynamic_sections()\n"); the .dynamic section. The DT_DEBUG entry is filled in by the dynamic linker and used by the debugger. */ #define add_dynamic_entry(TAG, VAL) \ - bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL)) + _bfd_elf_add_dynamic_entry (info, TAG, VAL) if (! info->shared) { diff --git a/bfd/elf32-m68hc1x.c b/bfd/elf32-m68hc1x.c index 00b75df0a7a..9de2f8b20e6 100644 --- a/bfd/elf32-m68hc1x.c +++ b/bfd/elf32-m68hc1x.c @@ -181,7 +181,7 @@ m68hc12_add_stub (const char *stub_name, asection *section, bfd_boolean elf32_m68hc11_add_symbol_hook (bfd *abfd, struct bfd_link_info *info, - const Elf_Internal_Sym *sym, + Elf_Internal_Sym *sym, const char **namep ATTRIBUTE_UNUSED, flagword *flagsp ATTRIBUTE_UNUSED, asection **secp ATTRIBUTE_UNUSED, diff --git a/bfd/elf32-m68hc1x.h b/bfd/elf32-m68hc1x.h index 59640232d80..f6b2001a334 100644 --- a/bfd/elf32-m68hc1x.h +++ b/bfd/elf32-m68hc1x.h @@ -1,5 +1,5 @@ /* Motorola 68HC11/68HC12-specific support for 32-bit ELF - Copyright 2003 Free Software Foundation, Inc. + Copyright 2003, 2004 Free Software Foundation, Inc. Contributed by Stephane Carrez (stcarrez@nerim.fr) This file is part of BFD, the Binary File Descriptor library. @@ -178,7 +178,7 @@ bfd_boolean elf32_m68hc11_relocate_section bfd_boolean elf32_m68hc11_add_symbol_hook (bfd *abfd, struct bfd_link_info *info, - const Elf_Internal_Sym *sym, const char **namep, + Elf_Internal_Sym *sym, const char **namep, flagword *flagsp, asection **secp, bfd_vma *valp); diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c index f1bdd1a8f1b..9864ef2efa8 100644 --- a/bfd/elf32-m68k.c +++ b/bfd/elf32-m68k.c @@ -1247,7 +1247,7 @@ elf_m68k_size_dynamic_sections (output_bfd, info) the .dynamic section. The DT_DEBUG entry is filled in by the dynamic linker and used by the debugger. */ #define add_dynamic_entry(TAG, VAL) \ - bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL)) + _bfd_elf_add_dynamic_entry (info, TAG, VAL) if (!info->shared) { diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index 5798ecaf20f..515a9296b84 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -3470,7 +3470,7 @@ ppc_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, the .dynamic section. The DT_DEBUG entry is filled in by the dynamic linker and used by the debugger. */ #define add_dynamic_entry(TAG, VAL) \ - bfd_elf32_add_dynamic_entry (info, (TAG), (VAL)) + _bfd_elf_add_dynamic_entry (info, TAG, VAL) if (info->executable) { @@ -4376,7 +4376,7 @@ ppc_elf_tls_optimize (bfd *obfd ATTRIBUTE_UNUSED, static bfd_boolean ppc_elf_add_symbol_hook (bfd *abfd, struct bfd_link_info *info, - const Elf_Internal_Sym *sym, + Elf_Internal_Sym *sym, const char **namep ATTRIBUTE_UNUSED, flagword *flagsp ATTRIBUTE_UNUSED, asection **secp, diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c index bb88dff781f..eabd070a77d 100644 --- a/bfd/elf32-s390.c +++ b/bfd/elf32-s390.c @@ -2157,7 +2157,7 @@ elf_s390_size_dynamic_sections (output_bfd, info) the .dynamic section. The DT_DEBUG entry is filled in by the dynamic linker and used by the debugger. */ #define add_dynamic_entry(TAG, VAL) \ - bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL)) + _bfd_elf_add_dynamic_entry (info, TAG, VAL) if (info->executable) { diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c index 28a2fcc5ad4..3ec6638d6ce 100644 --- a/bfd/elf32-sh.c +++ b/bfd/elf32-sh.c @@ -4620,7 +4620,7 @@ sh_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, the .dynamic section. The DT_DEBUG entry is filled in by the dynamic linker and used by the debugger. */ #define add_dynamic_entry(TAG, VAL) \ - bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL)) + _bfd_elf_add_dynamic_entry (info, TAG, VAL) if (info->executable) { diff --git a/bfd/elf32-sh64.c b/bfd/elf32-sh64.c index eac444af462..f013e6fea8f 100644 --- a/bfd/elf32-sh64.c +++ b/bfd/elf32-sh64.c @@ -1,5 +1,5 @@ /* SuperH SH64-specific support for 32-bit ELF - Copyright 2000, 2001, 2002, 2003 Free Software Foundation, Inc. + Copyright 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -56,7 +56,7 @@ static bfd_boolean shmedia_prepare_reloc static int sh64_elf_get_symbol_type (Elf_Internal_Sym *, int); static bfd_boolean sh64_elf_add_symbol_hook - (bfd *, struct bfd_link_info *, const Elf_Internal_Sym *, const char **, + (bfd *, struct bfd_link_info *, Elf_Internal_Sym *, const char **, flagword *, asection **, bfd_vma *); static bfd_boolean sh64_elf_link_output_symbol_hook (struct bfd_link_info *, const char *, Elf_Internal_Sym *, asection *, @@ -374,7 +374,7 @@ sh64_elf_get_symbol_type (Elf_Internal_Sym *elf_sym, int type) static bfd_boolean sh64_elf_add_symbol_hook (bfd *abfd, struct bfd_link_info *info, - const Elf_Internal_Sym *sym, const char **namep, + Elf_Internal_Sym *sym, const char **namep, flagword *flagsp ATTRIBUTE_UNUSED, asection **secp, bfd_vma *valp) { diff --git a/bfd/elf32-sparc.c b/bfd/elf32-sparc.c index 0f8afe0cfa3..9f8f9ab8151 100644 --- a/bfd/elf32-sparc.c +++ b/bfd/elf32-sparc.c @@ -2027,7 +2027,7 @@ elf32_sparc_size_dynamic_sections (output_bfd, info) the .dynamic section. The DT_DEBUG entry is filled in by the dynamic linker and used by the debugger. */ #define add_dynamic_entry(TAG, VAL) \ - bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL)) + _bfd_elf_add_dynamic_entry (info, TAG, VAL) if (info->executable) { diff --git a/bfd/elf32-v850.c b/bfd/elf32-v850.c index 747095213e7..2aba9cd5a86 100644 --- a/bfd/elf32-v850.c +++ b/bfd/elf32-v850.c @@ -73,7 +73,7 @@ static bfd_boolean v850_elf_section_from_bfd_section static void v850_elf_symbol_processing PARAMS ((bfd *, asymbol *)); static bfd_boolean v850_elf_add_symbol_hook - PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *, + PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Sym *, const char **, flagword *, asection **, bfd_vma *)); static bfd_boolean v850_elf_link_output_symbol_hook PARAMS ((struct bfd_link_info *, const char *, Elf_Internal_Sym *, @@ -2124,7 +2124,7 @@ static bfd_boolean v850_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) bfd *abfd; struct bfd_link_info *info ATTRIBUTE_UNUSED; - const Elf_Internal_Sym *sym; + Elf_Internal_Sym *sym; const char **namep ATTRIBUTE_UNUSED; flagword *flagsp ATTRIBUTE_UNUSED; asection **secp; diff --git a/bfd/elf32-vax.c b/bfd/elf32-vax.c index d2d5905e3e3..e6dc4a01bb3 100644 --- a/bfd/elf32-vax.c +++ b/bfd/elf32-vax.c @@ -1297,7 +1297,7 @@ elf_vax_size_dynamic_sections (output_bfd, info) the .dynamic section. The DT_DEBUG entry is filled in by the dynamic linker and used by the debugger. */ #define add_dynamic_entry(TAG, VAL) \ - bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL)) + _bfd_elf_add_dynamic_entry (info, TAG, VAL) if (!info->shared) { diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c index c376a170151..6cb987c2b86 100644 --- a/bfd/elf32-xtensa.c +++ b/bfd/elf32-xtensa.c @@ -1334,7 +1334,7 @@ elf_xtensa_size_dynamic_sections (output_bfd, info) the .dynamic section. The DT_DEBUG entry is filled in by the dynamic linker and used by the debugger. */ #define add_dynamic_entry(TAG, VAL) \ - bfd_elf32_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL)) + _bfd_elf_add_dynamic_entry (info, TAG, VAL) if (! info->shared) { diff --git a/bfd/elf64-alpha.c b/bfd/elf64-alpha.c index 22c12c0602a..1683683f775 100644 --- a/bfd/elf64-alpha.c +++ b/bfd/elf64-alpha.c @@ -123,7 +123,7 @@ static bfd_boolean elf64_alpha_size_rela_got_section static bfd_boolean elf64_alpha_size_rela_got_1 PARAMS ((struct alpha_elf_link_hash_entry *, struct bfd_link_info *)); static bfd_boolean elf64_alpha_add_symbol_hook - PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *, + PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Sym *, const char **, flagword *, asection **, bfd_vma *)); static struct alpha_elf_got_entry *get_got_entry PARAMS ((bfd *, struct alpha_elf_link_hash_entry *, unsigned long, @@ -2363,7 +2363,7 @@ static bfd_boolean elf64_alpha_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) bfd *abfd; struct bfd_link_info *info; - const Elf_Internal_Sym *sym; + Elf_Internal_Sym *sym; const char **namep ATTRIBUTE_UNUSED; flagword *flagsp ATTRIBUTE_UNUSED; asection **secp; @@ -4094,7 +4094,7 @@ elf64_alpha_size_dynamic_sections (output_bfd, info) the .dynamic section. The DT_DEBUG entry is filled in by the dynamic linker and used by the debugger. */ #define add_dynamic_entry(TAG, VAL) \ - bfd_elf64_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL)) + _bfd_elf_add_dynamic_entry (info, TAG, VAL) if (info->executable) { diff --git a/bfd/elf64-gen.c b/bfd/elf64-gen.c index 590456ccbf6..be1dc3e00ed 100644 --- a/bfd/elf64-gen.c +++ b/bfd/elf64-gen.c @@ -1,5 +1,6 @@ /* Generic support for 64-bit ELF - Copyright 1993, 1995, 1998, 1999, 2001, 2002 Free Software Foundation, Inc. + Copyright 1993, 1995, 1998, 1999, 2001, 2002, 2004 + Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -87,7 +88,7 @@ elf64_generic_link_add_symbols (abfd, info) return FALSE; } - return bfd_elf64_bfd_link_add_symbols (abfd, info); + return bfd_elf_link_add_symbols (abfd, info); } #define TARGET_LITTLE_SYM bfd_elf64_little_generic_vec diff --git a/bfd/elf64-hppa.c b/bfd/elf64-hppa.c index 5bc9309cb31..d64eca28c9b 100644 --- a/bfd/elf64-hppa.c +++ b/bfd/elf64-hppa.c @@ -1,5 +1,6 @@ /* Support for HPPA 64-bit ELF - Copyright 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. + Copyright 1999, 2000, 2001, 2002, 2003, 2004 + Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -1832,7 +1833,7 @@ elf64_hppa_size_dynamic_sections (output_bfd, info) the PLT, it is how we communicate the __gp value of a load module to the dynamic linker. */ #define add_dynamic_entry(TAG, VAL) \ - bfd_elf64_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL)) + _bfd_elf_add_dynamic_entry (info, TAG, VAL) if (!add_dynamic_entry (DT_HP_DLD_FLAGS, 0) || !add_dynamic_entry (DT_PLTGOT, 0)) diff --git a/bfd/elf64-mmix.c b/bfd/elf64-mmix.c index 0e1da0650ec..7f34a83b679 100644 --- a/bfd/elf64-mmix.c +++ b/bfd/elf64-mmix.c @@ -205,7 +205,7 @@ static bfd_boolean mmix_elf_section_from_bfd_section PARAMS ((bfd *, asection *, int *)); static bfd_boolean mmix_elf_add_symbol_hook - PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *, + PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Sym *, const char **, flagword *, asection **, bfd_vma *)); static bfd_boolean mmix_elf_is_local_label_name @@ -2175,7 +2175,7 @@ bfd_boolean mmix_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) bfd *abfd; struct bfd_link_info *info ATTRIBUTE_UNUSED; - const Elf_Internal_Sym *sym; + Elf_Internal_Sym *sym; const char **namep ATTRIBUTE_UNUSED; flagword *flagsp ATTRIBUTE_UNUSED; asection **secp; diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index d8f0b5e4220..a2aebfea212 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -82,6 +82,7 @@ static bfd_reloc_status_type ppc64_elf_unhandled_reloc #define elf_backend_grok_psinfo ppc64_elf_grok_psinfo #define elf_backend_create_dynamic_sections ppc64_elf_create_dynamic_sections #define elf_backend_copy_indirect_symbol ppc64_elf_copy_indirect_symbol +#define elf_backend_add_symbol_hook ppc64_elf_add_symbol_hook #define elf_backend_check_relocs ppc64_elf_check_relocs #define elf_backend_gc_mark_hook ppc64_elf_gc_mark_hook #define elf_backend_gc_sweep_hook ppc64_elf_gc_sweep_hook @@ -3474,6 +3475,22 @@ ppc64_elf_mark_entry_syms (struct bfd_link_info *info) return TRUE; } +/* Hack symbols defined in .opd sections to be function type. */ + +static bfd_boolean +ppc64_elf_add_symbol_hook (bfd *ibfd ATTRIBUTE_UNUSED, + struct bfd_link_info *info ATTRIBUTE_UNUSED, + Elf_Internal_Sym *isym, + const char **name ATTRIBUTE_UNUSED, + flagword *flags ATTRIBUTE_UNUSED, + asection **sec, + bfd_vma *value ATTRIBUTE_UNUSED) +{ + if (strcmp (bfd_get_section_name (ibfd, *sec), ".opd") == 0) + isym->st_info = ELF_ST_INFO (ELF_ST_BIND (isym->st_info), STT_FUNC); + return TRUE; +} + static bfd_boolean update_local_sym_info (bfd *abfd, Elf_Internal_Shdr *symtab_hdr, unsigned long r_symndx, bfd_vma r_addend, int tls_type) @@ -6065,7 +6082,7 @@ ppc64_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, the .dynamic section. The DT_DEBUG entry is filled in by the dynamic linker and used by the debugger. */ #define add_dynamic_entry(TAG, VAL) \ - bfd_elf64_add_dynamic_entry (info, (TAG), (VAL)) + _bfd_elf_add_dynamic_entry (info, TAG, VAL) if (info->executable) { diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c index 3bf26bc3af3..c35c0a9d73b 100644 --- a/bfd/elf64-s390.c +++ b/bfd/elf64-s390.c @@ -2127,7 +2127,7 @@ elf_s390_size_dynamic_sections (output_bfd, info) the .dynamic section. The DT_DEBUG entry is filled in by the dynamic linker and used by the debugger. */ #define add_dynamic_entry(TAG, VAL) \ - bfd_elf64_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL)) + _bfd_elf_add_dynamic_entry (info, TAG, VAL) if (info->executable) { diff --git a/bfd/elf64-sh64.c b/bfd/elf64-sh64.c index 03196c57d97..87b754e31bd 100644 --- a/bfd/elf64-sh64.c +++ b/bfd/elf64-sh64.c @@ -1,5 +1,5 @@ /* SuperH SH64-specific support for 64-bit ELF - Copyright 2000, 2001, 2002, 2003 Free Software Foundation, Inc. + Copyright 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -141,7 +141,7 @@ static bfd_boolean sh_elf64_check_relocs static int sh64_elf64_get_symbol_type (Elf_Internal_Sym *, int); static bfd_boolean sh64_elf64_add_symbol_hook - (bfd *, struct bfd_link_info *, const Elf_Internal_Sym *, const char **, + (bfd *, struct bfd_link_info *, Elf_Internal_Sym *, const char **, flagword *, asection **, bfd_vma *); static bfd_boolean sh64_elf64_link_output_symbol_hook (struct bfd_link_info *, const char *, Elf_Internal_Sym *, asection *, @@ -2887,7 +2887,7 @@ sh64_elf64_get_symbol_type (Elf_Internal_Sym * elf_sym, int type) static bfd_boolean sh64_elf64_add_symbol_hook (bfd *abfd, struct bfd_link_info *info, - const Elf_Internal_Sym *sym, const char **namep, + Elf_Internal_Sym *sym, const char **namep, flagword *flagsp ATTRIBUTE_UNUSED, asection **secp, bfd_vma *valp) { @@ -3728,31 +3728,31 @@ sh64_elf64_size_dynamic_sections (bfd *output_bfd, dynamic linker and used by the debugger. */ if (info->executable) { - if (! bfd_elf64_add_dynamic_entry (info, DT_DEBUG, 0)) + if (!_bfd_elf_add_dynamic_entry (info, DT_DEBUG, 0)) return FALSE; } if (plt) { - if (! bfd_elf64_add_dynamic_entry (info, DT_PLTGOT, 0) - || ! bfd_elf64_add_dynamic_entry (info, DT_PLTRELSZ, 0) - || ! bfd_elf64_add_dynamic_entry (info, DT_PLTREL, DT_RELA) - || ! bfd_elf64_add_dynamic_entry (info, DT_JMPREL, 0)) + if (!_bfd_elf_add_dynamic_entry (info, DT_PLTGOT, 0) + || !_bfd_elf_add_dynamic_entry (info, DT_PLTRELSZ, 0) + || !_bfd_elf_add_dynamic_entry (info, DT_PLTREL, DT_RELA) + || !_bfd_elf_add_dynamic_entry (info, DT_JMPREL, 0)) return FALSE; } if (relocs) { - if (! bfd_elf64_add_dynamic_entry (info, DT_RELA, 0) - || ! bfd_elf64_add_dynamic_entry (info, DT_RELASZ, 0) - || ! bfd_elf64_add_dynamic_entry (info, DT_RELAENT, - sizeof (Elf64_External_Rela))) + if (!_bfd_elf_add_dynamic_entry (info, DT_RELA, 0) + || !_bfd_elf_add_dynamic_entry (info, DT_RELASZ, 0) + || !_bfd_elf_add_dynamic_entry (info, DT_RELAENT, + sizeof (Elf64_External_Rela))) return FALSE; } if (reltext) { - if (! bfd_elf64_add_dynamic_entry (info, DT_TEXTREL, 0)) + if (!_bfd_elf_add_dynamic_entry (info, DT_TEXTREL, 0)) return FALSE; } } diff --git a/bfd/elf64-sparc.c b/bfd/elf64-sparc.c index 001f3a5a77b..6c9d302564e 100644 --- a/bfd/elf64-sparc.c +++ b/bfd/elf64-sparc.c @@ -1,6 +1,6 @@ /* SPARC-specific support for 64-bit ELF Copyright 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, - 2003 Free Software Foundation, Inc. + 2003, 2004 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -61,7 +61,7 @@ static bfd_boolean sparc64_elf_size_dynamic_sections static int sparc64_elf_get_symbol_type PARAMS (( Elf_Internal_Sym *, int)); static bfd_boolean sparc64_elf_add_symbol_hook - PARAMS ((bfd *, struct bfd_link_info *, const Elf_Internal_Sym *, + PARAMS ((bfd *, struct bfd_link_info *, Elf_Internal_Sym *, const char **, flagword *, asection **, bfd_vma *)); static bfd_boolean sparc64_elf_output_arch_syms PARAMS ((bfd *, struct bfd_link_info *, PTR, @@ -1385,7 +1385,7 @@ static bfd_boolean sparc64_elf_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) bfd *abfd; struct bfd_link_info *info; - const Elf_Internal_Sym *sym; + Elf_Internal_Sym *sym; const char **namep; flagword *flagsp ATTRIBUTE_UNUSED; asection **secp ATTRIBUTE_UNUSED; @@ -1876,7 +1876,7 @@ sparc64_elf_size_dynamic_sections (output_bfd, info) the .dynamic section. The DT_DEBUG entry is filled in by the dynamic linker and used by the debugger. */ #define add_dynamic_entry(TAG, VAL) \ - bfd_elf64_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL)) + _bfd_elf_add_dynamic_entry (info, TAG, VAL) int reg; struct sparc64_elf_app_reg * app_regs; diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c index 528f7a84ebb..1aadfe579d1 100644 --- a/bfd/elf64-x86-64.c +++ b/bfd/elf64-x86-64.c @@ -1683,7 +1683,7 @@ elf64_x86_64_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, the .dynamic section. The DT_DEBUG entry is filled in by the dynamic linker and used by the debugger. */ #define add_dynamic_entry(TAG, VAL) \ - bfd_elf64_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL)) + _bfd_elf_add_dynamic_entry (info, TAG, VAL) if (info->executable) { diff --git a/bfd/elfcode.h b/bfd/elfcode.h index 87d96fafc6d..d0dd9eddfbd 100644 --- a/bfd/elfcode.h +++ b/bfd/elfcode.h @@ -115,8 +115,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define elf_no_info_to_howto NAME(bfd_elf,no_info_to_howto) #define elf_no_info_to_howto_rel NAME(bfd_elf,no_info_to_howto_rel) #define elf_find_section NAME(bfd_elf,find_section) -#define elf_bfd_link_add_symbols NAME(bfd_elf,bfd_link_add_symbols) -#define elf_add_dynamic_entry NAME(bfd_elf,add_dynamic_entry) #define elf_write_shdrs_and_ehdr NAME(bfd_elf,write_shdrs_and_ehdr) #define elf_write_out_phdrs NAME(bfd_elf,write_out_phdrs) #define elf_write_relocs NAME(bfd_elf,write_relocs) diff --git a/bfd/elflink.c b/bfd/elflink.c index 39bf46f769e..a11e7cdea8d 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -24,6 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "libbfd.h" #define ARCH_SIZE 0 #include "elf-bfd.h" +#include "safe-ctype.h" bfd_boolean _bfd_elf_create_got_section (bfd *abfd, struct bfd_link_info *info) @@ -2585,6 +2586,1565 @@ elf_link_is_defined_archive_symbol (bfd * abfd, carsym * symdef) return result; } +/* Add an entry to the .dynamic table. */ + +bfd_boolean +_bfd_elf_add_dynamic_entry (struct bfd_link_info *info, + bfd_vma tag, + bfd_vma val) +{ + struct elf_link_hash_table *hash_table; + const struct elf_backend_data *bed; + asection *s; + bfd_size_type newsize; + bfd_byte *newcontents; + Elf_Internal_Dyn dyn; + + hash_table = elf_hash_table (info); + if (! is_elf_hash_table (hash_table)) + return FALSE; + + bed = get_elf_backend_data (hash_table->dynobj); + s = bfd_get_section_by_name (hash_table->dynobj, ".dynamic"); + BFD_ASSERT (s != NULL); + + newsize = s->_raw_size + bed->s->sizeof_dyn; + newcontents = bfd_realloc (s->contents, newsize); + if (newcontents == NULL) + return FALSE; + + dyn.d_tag = tag; + dyn.d_un.d_val = val; + bed->s->swap_dyn_out (hash_table->dynobj, &dyn, newcontents + s->_raw_size); + + s->_raw_size = newsize; + s->contents = newcontents; + + return TRUE; +} + +/* Add a DT_NEEDED entry for this dynamic object if DO_IT is true, + otherwise just check whether one already exists. Returns -1 on error, + 1 if a DT_NEEDED tag already exists, and 0 on success. */ + +static int +elf_add_dt_needed_tag (struct bfd_link_info *info, + const char *soname, + bfd_boolean do_it) +{ + struct elf_link_hash_table *hash_table; + bfd_size_type oldsize; + bfd_size_type strindex; + + hash_table = elf_hash_table (info); + oldsize = _bfd_elf_strtab_size (hash_table->dynstr); + strindex = _bfd_elf_strtab_add (hash_table->dynstr, soname, FALSE); + if (strindex == (bfd_size_type) -1) + return -1; + + if (oldsize == _bfd_elf_strtab_size (hash_table->dynstr)) + { + asection *sdyn; + const struct elf_backend_data *bed; + bfd_byte *extdyn; + + bed = get_elf_backend_data (hash_table->dynobj); + sdyn = bfd_get_section_by_name (hash_table->dynobj, ".dynamic"); + BFD_ASSERT (sdyn != NULL); + + for (extdyn = sdyn->contents; + extdyn < sdyn->contents + sdyn->_raw_size; + extdyn += bed->s->sizeof_dyn) + { + Elf_Internal_Dyn dyn; + + bed->s->swap_dyn_in (hash_table->dynobj, extdyn, &dyn); + if (dyn.d_tag == DT_NEEDED + && dyn.d_un.d_val == strindex) + { + _bfd_elf_strtab_delref (hash_table->dynstr, strindex); + return 1; + } + } + } + + if (do_it) + { + if (!_bfd_elf_add_dynamic_entry (info, DT_NEEDED, strindex)) + return -1; + } + else + /* We were just checking for existence of the tag. */ + _bfd_elf_strtab_delref (hash_table->dynstr, strindex); + + return 0; +} + +/* Sort symbol by value and section. */ +static int +elf_sort_symbol (const void *arg1, const void *arg2) +{ + const struct elf_link_hash_entry *h1; + const struct elf_link_hash_entry *h2; + bfd_signed_vma vdiff; + + h1 = *(const struct elf_link_hash_entry **) arg1; + h2 = *(const struct elf_link_hash_entry **) arg2; + vdiff = h1->root.u.def.value - h2->root.u.def.value; + if (vdiff != 0) + return vdiff > 0 ? 1 : -1; + else + { + long sdiff = h1->root.u.def.section - h2->root.u.def.section; + if (sdiff != 0) + return sdiff > 0 ? 1 : -1; + } + return 0; +} + +/* This function is used to adjust offsets into .dynstr for + dynamic symbols. This is called via elf_link_hash_traverse. */ + +static bfd_boolean +elf_adjust_dynstr_offsets (struct elf_link_hash_entry *h, void *data) +{ + struct elf_strtab_hash *dynstr = data; + + if (h->root.type == bfd_link_hash_warning) + h = (struct elf_link_hash_entry *) h->root.u.i.link; + + if (h->dynindx != -1) + h->dynstr_index = _bfd_elf_strtab_offset (dynstr, h->dynstr_index); + return TRUE; +} + +/* Assign string offsets in .dynstr, update all structures referencing + them. */ + +static bfd_boolean +elf_finalize_dynstr (bfd *output_bfd, struct bfd_link_info *info) +{ + struct elf_link_hash_table *hash_table = elf_hash_table (info); + struct elf_link_local_dynamic_entry *entry; + struct elf_strtab_hash *dynstr = hash_table->dynstr; + bfd *dynobj = hash_table->dynobj; + asection *sdyn; + bfd_size_type size; + const struct elf_backend_data *bed; + bfd_byte *extdyn; + + _bfd_elf_strtab_finalize (dynstr); + size = _bfd_elf_strtab_size (dynstr); + + bed = get_elf_backend_data (dynobj); + sdyn = bfd_get_section_by_name (dynobj, ".dynamic"); + BFD_ASSERT (sdyn != NULL); + + /* Update all .dynamic entries referencing .dynstr strings. */ + for (extdyn = sdyn->contents; + extdyn < sdyn->contents + sdyn->_raw_size; + extdyn += bed->s->sizeof_dyn) + { + Elf_Internal_Dyn dyn; + + bed->s->swap_dyn_in (dynobj, extdyn, &dyn); + switch (dyn.d_tag) + { + case DT_STRSZ: + dyn.d_un.d_val = size; + break; + case DT_NEEDED: + case DT_SONAME: + case DT_RPATH: + case DT_RUNPATH: + case DT_FILTER: + case DT_AUXILIARY: + dyn.d_un.d_val = _bfd_elf_strtab_offset (dynstr, dyn.d_un.d_val); + break; + default: + continue; + } + bed->s->swap_dyn_out (dynobj, &dyn, extdyn); + } + + /* Now update local dynamic symbols. */ + for (entry = hash_table->dynlocal; entry ; entry = entry->next) + entry->isym.st_name = _bfd_elf_strtab_offset (dynstr, + entry->isym.st_name); + + /* And the rest of dynamic symbols. */ + elf_link_hash_traverse (hash_table, elf_adjust_dynstr_offsets, dynstr); + + /* Adjust version definitions. */ + if (elf_tdata (output_bfd)->cverdefs) + { + asection *s; + bfd_byte *p; + bfd_size_type i; + Elf_Internal_Verdef def; + Elf_Internal_Verdaux defaux; + + s = bfd_get_section_by_name (dynobj, ".gnu.version_d"); + p = s->contents; + do + { + _bfd_elf_swap_verdef_in (output_bfd, (Elf_External_Verdef *) p, + &def); + p += sizeof (Elf_External_Verdef); + for (i = 0; i < def.vd_cnt; ++i) + { + _bfd_elf_swap_verdaux_in (output_bfd, + (Elf_External_Verdaux *) p, &defaux); + defaux.vda_name = _bfd_elf_strtab_offset (dynstr, + defaux.vda_name); + _bfd_elf_swap_verdaux_out (output_bfd, + &defaux, (Elf_External_Verdaux *) p); + p += sizeof (Elf_External_Verdaux); + } + } + while (def.vd_next); + } + + /* Adjust version references. */ + if (elf_tdata (output_bfd)->verref) + { + asection *s; + bfd_byte *p; + bfd_size_type i; + Elf_Internal_Verneed need; + Elf_Internal_Vernaux needaux; + + s = bfd_get_section_by_name (dynobj, ".gnu.version_r"); + p = s->contents; + do + { + _bfd_elf_swap_verneed_in (output_bfd, (Elf_External_Verneed *) p, + &need); + need.vn_file = _bfd_elf_strtab_offset (dynstr, need.vn_file); + _bfd_elf_swap_verneed_out (output_bfd, &need, + (Elf_External_Verneed *) p); + p += sizeof (Elf_External_Verneed); + for (i = 0; i < need.vn_cnt; ++i) + { + _bfd_elf_swap_vernaux_in (output_bfd, + (Elf_External_Vernaux *) p, &needaux); + needaux.vna_name = _bfd_elf_strtab_offset (dynstr, + needaux.vna_name); + _bfd_elf_swap_vernaux_out (output_bfd, + &needaux, + (Elf_External_Vernaux *) p); + p += sizeof (Elf_External_Vernaux); + } + } + while (need.vn_next); + } + + return TRUE; +} + +/* Add symbols from an ELF object file to the linker hash table. */ + +static bfd_boolean +elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) +{ + bfd_boolean (*add_symbol_hook) + (bfd *, struct bfd_link_info *, Elf_Internal_Sym *, + const char **, flagword *, asection **, bfd_vma *); + bfd_boolean (*check_relocs) + (bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *); + bfd_boolean collect; + Elf_Internal_Shdr *hdr; + bfd_size_type symcount; + bfd_size_type extsymcount; + bfd_size_type extsymoff; + struct elf_link_hash_entry **sym_hash; + bfd_boolean dynamic; + Elf_External_Versym *extversym = NULL; + Elf_External_Versym *ever; + struct elf_link_hash_entry *weaks; + struct elf_link_hash_entry **nondeflt_vers = NULL; + bfd_size_type nondeflt_vers_cnt = 0; + Elf_Internal_Sym *isymbuf = NULL; + Elf_Internal_Sym *isym; + Elf_Internal_Sym *isymend; + const struct elf_backend_data *bed; + bfd_boolean add_needed; + struct elf_link_hash_table * hash_table; + bfd_size_type amt; + + hash_table = elf_hash_table (info); + + bed = get_elf_backend_data (abfd); + add_symbol_hook = bed->elf_add_symbol_hook; + collect = bed->collect; + + if ((abfd->flags & DYNAMIC) == 0) + dynamic = FALSE; + else + { + dynamic = TRUE; + + /* You can't use -r against a dynamic object. Also, there's no + hope of using a dynamic object which does not exactly match + the format of the output file. */ + if (info->relocatable + || !is_elf_hash_table (hash_table) + || hash_table->root.creator != abfd->xvec) + { + bfd_set_error (bfd_error_invalid_operation); + goto error_return; + } + } + + /* As a GNU extension, any input sections which are named + .gnu.warning.SYMBOL are treated as warning symbols for the given + symbol. This differs from .gnu.warning sections, which generate + warnings when they are included in an output file. */ + if (info->executable) + { + asection *s; + + for (s = abfd->sections; s != NULL; s = s->next) + { + const char *name; + + name = bfd_get_section_name (abfd, s); + if (strncmp (name, ".gnu.warning.", sizeof ".gnu.warning." - 1) == 0) + { + char *msg; + bfd_size_type sz; + bfd_size_type prefix_len; + const char * gnu_warning_prefix = _("warning: "); + + name += sizeof ".gnu.warning." - 1; + + /* If this is a shared object, then look up the symbol + in the hash table. If it is there, and it is already + been defined, then we will not be using the entry + from this shared object, so we don't need to warn. + FIXME: If we see the definition in a regular object + later on, we will warn, but we shouldn't. The only + fix is to keep track of what warnings we are supposed + to emit, and then handle them all at the end of the + link. */ + if (dynamic) + { + struct elf_link_hash_entry *h; + + h = elf_link_hash_lookup (hash_table, name, + FALSE, FALSE, TRUE); + + /* FIXME: What about bfd_link_hash_common? */ + if (h != NULL + && (h->root.type == bfd_link_hash_defined + || h->root.type == bfd_link_hash_defweak)) + { + /* We don't want to issue this warning. Clobber + the section size so that the warning does not + get copied into the output file. */ + s->_raw_size = 0; + continue; + } + } + + sz = bfd_section_size (abfd, s); + prefix_len = strlen (gnu_warning_prefix); + msg = bfd_alloc (abfd, prefix_len + sz + 1); + if (msg == NULL) + goto error_return; + + strcpy (msg, gnu_warning_prefix); + if (! bfd_get_section_contents (abfd, s, msg + prefix_len, 0, sz)) + goto error_return; + + msg[prefix_len + sz] = '\0'; + + if (! (_bfd_generic_link_add_one_symbol + (info, abfd, name, BSF_WARNING, s, 0, msg, + FALSE, collect, NULL))) + goto error_return; + + if (! info->relocatable) + { + /* Clobber the section size so that the warning does + not get copied into the output file. */ + s->_raw_size = 0; + } + } + } + } + + add_needed = TRUE; + if (! dynamic) + { + /* If we are creating a shared library, create all the dynamic + sections immediately. We need to attach them to something, + so we attach them to this BFD, provided it is the right + format. FIXME: If there are no input BFD's of the same + format as the output, we can't make a shared library. */ + if (info->shared + && is_elf_hash_table (hash_table) + && hash_table->root.creator == abfd->xvec + && ! hash_table->dynamic_sections_created) + { + if (! _bfd_elf_link_create_dynamic_sections (abfd, info)) + goto error_return; + } + } + else if (!is_elf_hash_table (hash_table)) + goto error_return; + else + { + asection *s; + const char *soname = NULL; + struct bfd_link_needed_list *rpath = NULL, *runpath = NULL; + int ret; + + /* ld --just-symbols and dynamic objects don't mix very well. + Test for --just-symbols by looking at info set up by + _bfd_elf_link_just_syms. */ + if ((s = abfd->sections) != NULL + && s->sec_info_type == ELF_INFO_TYPE_JUST_SYMS) + goto error_return; + + /* If this dynamic lib was specified on the command line with + --as-needed in effect, then we don't want to add a DT_NEEDED + tag unless the lib is actually used. Similary for libs brought + in by another lib's DT_NEEDED. */ + add_needed = elf_dyn_lib_class (abfd) == DYN_NORMAL; + + s = bfd_get_section_by_name (abfd, ".dynamic"); + if (s != NULL) + { + bfd_byte *dynbuf; + bfd_byte *extdyn; + int elfsec; + unsigned long shlink; + + dynbuf = bfd_malloc (s->_raw_size); + if (dynbuf == NULL) + goto error_return; + + if (! bfd_get_section_contents (abfd, s, dynbuf, 0, s->_raw_size)) + goto error_free_dyn; + + elfsec = _bfd_elf_section_from_bfd_section (abfd, s); + if (elfsec == -1) + goto error_free_dyn; + shlink = elf_elfsections (abfd)[elfsec]->sh_link; + + for (extdyn = dynbuf; + extdyn < dynbuf + s->_raw_size; + extdyn += bed->s->sizeof_dyn) + { + Elf_Internal_Dyn dyn; + + bed->s->swap_dyn_in (abfd, extdyn, &dyn); + if (dyn.d_tag == DT_SONAME) + { + unsigned int tagv = dyn.d_un.d_val; + soname = bfd_elf_string_from_elf_section (abfd, shlink, tagv); + if (soname == NULL) + goto error_free_dyn; + } + if (dyn.d_tag == DT_NEEDED) + { + struct bfd_link_needed_list *n, **pn; + char *fnm, *anm; + unsigned int tagv = dyn.d_un.d_val; + + amt = sizeof (struct bfd_link_needed_list); + n = bfd_alloc (abfd, amt); + fnm = bfd_elf_string_from_elf_section (abfd, shlink, tagv); + if (n == NULL || fnm == NULL) + goto error_free_dyn; + amt = strlen (fnm) + 1; + anm = bfd_alloc (abfd, amt); + if (anm == NULL) + goto error_free_dyn; + memcpy (anm, fnm, amt); + n->name = anm; + n->by = abfd; + n->next = NULL; + for (pn = & hash_table->needed; + *pn != NULL; + pn = &(*pn)->next) + ; + *pn = n; + } + if (dyn.d_tag == DT_RUNPATH) + { + struct bfd_link_needed_list *n, **pn; + char *fnm, *anm; + unsigned int tagv = dyn.d_un.d_val; + + amt = sizeof (struct bfd_link_needed_list); + n = bfd_alloc (abfd, amt); + fnm = bfd_elf_string_from_elf_section (abfd, shlink, tagv); + if (n == NULL || fnm == NULL) + goto error_free_dyn; + amt = strlen (fnm) + 1; + anm = bfd_alloc (abfd, amt); + if (anm == NULL) + goto error_free_dyn; + memcpy (anm, fnm, amt); + n->name = anm; + n->by = abfd; + n->next = NULL; + for (pn = & runpath; + *pn != NULL; + pn = &(*pn)->next) + ; + *pn = n; + } + /* Ignore DT_RPATH if we have seen DT_RUNPATH. */ + if (!runpath && dyn.d_tag == DT_RPATH) + { + struct bfd_link_needed_list *n, **pn; + char *fnm, *anm; + unsigned int tagv = dyn.d_un.d_val; + + amt = sizeof (struct bfd_link_needed_list); + n = bfd_alloc (abfd, amt); + fnm = bfd_elf_string_from_elf_section (abfd, shlink, tagv); + if (n == NULL || fnm == NULL) + goto error_free_dyn; + amt = strlen (fnm) + 1; + anm = bfd_alloc (abfd, amt); + if (anm == NULL) + { + error_free_dyn: + free (dynbuf); + goto error_return; + } + memcpy (anm, fnm, amt); + n->name = anm; + n->by = abfd; + n->next = NULL; + for (pn = & rpath; + *pn != NULL; + pn = &(*pn)->next) + ; + *pn = n; + } + } + + free (dynbuf); + } + + /* DT_RUNPATH overrides DT_RPATH. Do _NOT_ bfd_release, as that + frees all more recently bfd_alloc'd blocks as well. */ + if (runpath) + rpath = runpath; + + if (rpath) + { + struct bfd_link_needed_list **pn; + for (pn = & hash_table->runpath; + *pn != NULL; + pn = &(*pn)->next) + ; + *pn = rpath; + } + + /* We do not want to include any of the sections in a dynamic + object in the output file. We hack by simply clobbering the + list of sections in the BFD. This could be handled more + cleanly by, say, a new section flag; the existing + SEC_NEVER_LOAD flag is not the one we want, because that one + still implies that the section takes up space in the output + file. */ + bfd_section_list_clear (abfd); + + /* If this is the first dynamic object found in the link, create + the special sections required for dynamic linking. */ + if (! _bfd_elf_link_create_dynamic_sections (abfd, info)) + goto error_return; + + /* Find the name to use in a DT_NEEDED entry that refers to this + object. If the object has a DT_SONAME entry, we use it. + Otherwise, if the generic linker stuck something in + elf_dt_name, we use that. Otherwise, we just use the file + name. */ + if (soname == NULL || *soname == '\0') + { + soname = elf_dt_name (abfd); + if (soname == NULL || *soname == '\0') + soname = bfd_get_filename (abfd); + } + + /* Save the SONAME because sometimes the linker emulation code + will need to know it. */ + elf_dt_name (abfd) = soname; + + ret = elf_add_dt_needed_tag (info, soname, add_needed); + if (ret < 0) + goto error_return; + + /* If we have already included this dynamic object in the + link, just ignore it. There is no reason to include a + particular dynamic object more than once. */ + if (ret > 0) + return TRUE; + } + + /* If this is a dynamic object, we always link against the .dynsym + symbol table, not the .symtab symbol table. The dynamic linker + will only see the .dynsym symbol table, so there is no reason to + look at .symtab for a dynamic object. */ + + if (! dynamic || elf_dynsymtab (abfd) == 0) + hdr = &elf_tdata (abfd)->symtab_hdr; + else + hdr = &elf_tdata (abfd)->dynsymtab_hdr; + + symcount = hdr->sh_size / bed->s->sizeof_sym; + + /* The sh_info field of the symtab header tells us where the + external symbols start. We don't care about the local symbols at + this point. */ + if (elf_bad_symtab (abfd)) + { + extsymcount = symcount; + extsymoff = 0; + } + else + { + extsymcount = symcount - hdr->sh_info; + extsymoff = hdr->sh_info; + } + + sym_hash = NULL; + if (extsymcount != 0) + { + isymbuf = bfd_elf_get_elf_syms (abfd, hdr, extsymcount, extsymoff, + NULL, NULL, NULL); + if (isymbuf == NULL) + goto error_return; + + /* We store a pointer to the hash table entry for each external + symbol. */ + amt = extsymcount * sizeof (struct elf_link_hash_entry *); + sym_hash = bfd_alloc (abfd, amt); + if (sym_hash == NULL) + goto error_free_sym; + elf_sym_hashes (abfd) = sym_hash; + } + + if (dynamic) + { + /* Read in any version definitions. */ + if (! _bfd_elf_slurp_version_tables (abfd)) + goto error_free_sym; + + /* Read in the symbol versions, but don't bother to convert them + to internal format. */ + if (elf_dynversym (abfd) != 0) + { + Elf_Internal_Shdr *versymhdr; + + versymhdr = &elf_tdata (abfd)->dynversym_hdr; + extversym = bfd_malloc (versymhdr->sh_size); + if (extversym == NULL) + goto error_free_sym; + amt = versymhdr->sh_size; + if (bfd_seek (abfd, versymhdr->sh_offset, SEEK_SET) != 0 + || bfd_bread (extversym, amt, abfd) != amt) + goto error_free_vers; + } + } + + weaks = NULL; + + ever = extversym != NULL ? extversym + extsymoff : NULL; + for (isym = isymbuf, isymend = isymbuf + extsymcount; + isym < isymend; + isym++, sym_hash++, ever = (ever != NULL ? ever + 1 : NULL)) + { + int bind; + bfd_vma value; + asection *sec; + flagword flags; + const char *name; + struct elf_link_hash_entry *h; + bfd_boolean definition; + bfd_boolean size_change_ok; + bfd_boolean type_change_ok; + bfd_boolean new_weakdef; + bfd_boolean override; + unsigned int old_alignment; + bfd *old_bfd; + + override = FALSE; + + flags = BSF_NO_FLAGS; + sec = NULL; + value = isym->st_value; + *sym_hash = NULL; + + bind = ELF_ST_BIND (isym->st_info); + if (bind == STB_LOCAL) + { + /* This should be impossible, since ELF requires that all + global symbols follow all local symbols, and that sh_info + point to the first global symbol. Unfortunately, Irix 5 + screws this up. */ + continue; + } + else if (bind == STB_GLOBAL) + { + if (isym->st_shndx != SHN_UNDEF + && isym->st_shndx != SHN_COMMON) + flags = BSF_GLOBAL; + } + else if (bind == STB_WEAK) + flags = BSF_WEAK; + else + { + /* Leave it up to the processor backend. */ + } + + if (isym->st_shndx == SHN_UNDEF) + sec = bfd_und_section_ptr; + else if (isym->st_shndx < SHN_LORESERVE || isym->st_shndx > SHN_HIRESERVE) + { + sec = bfd_section_from_elf_index (abfd, isym->st_shndx); + if (sec == NULL) + sec = bfd_abs_section_ptr; + else if ((abfd->flags & (EXEC_P | DYNAMIC)) != 0) + value -= sec->vma; + } + else if (isym->st_shndx == SHN_ABS) + sec = bfd_abs_section_ptr; + else if (isym->st_shndx == SHN_COMMON) + { + sec = bfd_com_section_ptr; + /* What ELF calls the size we call the value. What ELF + calls the value we call the alignment. */ + value = isym->st_size; + } + else + { + /* Leave it up to the processor backend. */ + } + + name = bfd_elf_string_from_elf_section (abfd, hdr->sh_link, + isym->st_name); + if (name == NULL) + goto error_free_vers; + + if (isym->st_shndx == SHN_COMMON + && ELF_ST_TYPE (isym->st_info) == STT_TLS) + { + asection *tcomm = bfd_get_section_by_name (abfd, ".tcommon"); + + if (tcomm == NULL) + { + tcomm = bfd_make_section (abfd, ".tcommon"); + if (tcomm == NULL + || !bfd_set_section_flags (abfd, tcomm, (SEC_ALLOC + | SEC_IS_COMMON + | SEC_LINKER_CREATED + | SEC_THREAD_LOCAL))) + goto error_free_vers; + } + sec = tcomm; + } + else if (add_symbol_hook) + { + if (! (*add_symbol_hook) (abfd, info, isym, &name, &flags, &sec, + &value)) + goto error_free_vers; + + /* The hook function sets the name to NULL if this symbol + should be skipped for some reason. */ + if (name == NULL) + continue; + } + + /* Sanity check that all possibilities were handled. */ + if (sec == NULL) + { + bfd_set_error (bfd_error_bad_value); + goto error_free_vers; + } + + if (bfd_is_und_section (sec) + || bfd_is_com_section (sec)) + definition = FALSE; + else + definition = TRUE; + + size_change_ok = FALSE; + type_change_ok = get_elf_backend_data (abfd)->type_change_ok; + old_alignment = 0; + old_bfd = NULL; + + if (is_elf_hash_table (hash_table)) + { + Elf_Internal_Versym iver; + unsigned int vernum = 0; + bfd_boolean skip; + + if (ever != NULL) + { + _bfd_elf_swap_versym_in (abfd, ever, &iver); + vernum = iver.vs_vers & VERSYM_VERSION; + + /* If this is a hidden symbol, or if it is not version + 1, we append the version name to the symbol name. + However, we do not modify a non-hidden absolute + symbol, because it might be the version symbol + itself. FIXME: What if it isn't? */ + if ((iver.vs_vers & VERSYM_HIDDEN) != 0 + || (vernum > 1 && ! bfd_is_abs_section (sec))) + { + const char *verstr; + size_t namelen, verlen, newlen; + char *newname, *p; + + if (isym->st_shndx != SHN_UNDEF) + { + if (vernum > elf_tdata (abfd)->dynverdef_hdr.sh_info) + { + (*_bfd_error_handler) + (_("%s: %s: invalid version %u (max %d)"), + bfd_archive_filename (abfd), name, vernum, + elf_tdata (abfd)->dynverdef_hdr.sh_info); + bfd_set_error (bfd_error_bad_value); + goto error_free_vers; + } + else if (vernum > 1) + verstr = + elf_tdata (abfd)->verdef[vernum - 1].vd_nodename; + else + verstr = ""; + } + else + { + /* We cannot simply test for the number of + entries in the VERNEED section since the + numbers for the needed versions do not start + at 0. */ + Elf_Internal_Verneed *t; + + verstr = NULL; + for (t = elf_tdata (abfd)->verref; + t != NULL; + t = t->vn_nextref) + { + Elf_Internal_Vernaux *a; + + for (a = t->vn_auxptr; a != NULL; a = a->vna_nextptr) + { + if (a->vna_other == vernum) + { + verstr = a->vna_nodename; + break; + } + } + if (a != NULL) + break; + } + if (verstr == NULL) + { + (*_bfd_error_handler) + (_("%s: %s: invalid needed version %d"), + bfd_archive_filename (abfd), name, vernum); + bfd_set_error (bfd_error_bad_value); + goto error_free_vers; + } + } + + namelen = strlen (name); + verlen = strlen (verstr); + newlen = namelen + verlen + 2; + if ((iver.vs_vers & VERSYM_HIDDEN) == 0 + && isym->st_shndx != SHN_UNDEF) + ++newlen; + + newname = bfd_alloc (abfd, newlen); + if (newname == NULL) + goto error_free_vers; + memcpy (newname, name, namelen); + p = newname + namelen; + *p++ = ELF_VER_CHR; + /* If this is a defined non-hidden version symbol, + we add another @ to the name. This indicates the + default version of the symbol. */ + if ((iver.vs_vers & VERSYM_HIDDEN) == 0 + && isym->st_shndx != SHN_UNDEF) + *p++ = ELF_VER_CHR; + memcpy (p, verstr, verlen + 1); + + name = newname; + } + } + + if (!_bfd_elf_merge_symbol (abfd, info, name, isym, &sec, &value, + sym_hash, &skip, &override, + &type_change_ok, &size_change_ok)) + goto error_free_vers; + + if (skip) + continue; + + if (override) + definition = FALSE; + + h = *sym_hash; + while (h->root.type == bfd_link_hash_indirect + || h->root.type == bfd_link_hash_warning) + h = (struct elf_link_hash_entry *) h->root.u.i.link; + + /* Remember the old alignment if this is a common symbol, so + that we don't reduce the alignment later on. We can't + check later, because _bfd_generic_link_add_one_symbol + will set a default for the alignment which we want to + override. We also remember the old bfd where the existing + definition comes from. */ + switch (h->root.type) + { + default: + break; + + case bfd_link_hash_defined: + case bfd_link_hash_defweak: + old_bfd = h->root.u.def.section->owner; + break; + + case bfd_link_hash_common: + old_bfd = h->root.u.c.p->section->owner; + old_alignment = h->root.u.c.p->alignment_power; + break; + } + + if (elf_tdata (abfd)->verdef != NULL + && ! override + && vernum > 1 + && definition) + h->verinfo.verdef = &elf_tdata (abfd)->verdef[vernum - 1]; + } + + if (! (_bfd_generic_link_add_one_symbol + (info, abfd, name, flags, sec, value, NULL, FALSE, collect, + (struct bfd_link_hash_entry **) sym_hash))) + goto error_free_vers; + + h = *sym_hash; + while (h->root.type == bfd_link_hash_indirect + || h->root.type == bfd_link_hash_warning) + h = (struct elf_link_hash_entry *) h->root.u.i.link; + *sym_hash = h; + + new_weakdef = FALSE; + if (dynamic + && definition + && (flags & BSF_WEAK) != 0 + && ELF_ST_TYPE (isym->st_info) != STT_FUNC + && is_elf_hash_table (hash_table) + && h->weakdef == NULL) + { + /* Keep a list of all weak defined non function symbols from + a dynamic object, using the weakdef field. Later in this + function we will set the weakdef field to the correct + value. We only put non-function symbols from dynamic + objects on this list, because that happens to be the only + time we need to know the normal symbol corresponding to a + weak symbol, and the information is time consuming to + figure out. If the weakdef field is not already NULL, + then this symbol was already defined by some previous + dynamic object, and we will be using that previous + definition anyhow. */ + + h->weakdef = weaks; + weaks = h; + new_weakdef = TRUE; + } + + /* Set the alignment of a common symbol. */ + if (isym->st_shndx == SHN_COMMON + && h->root.type == bfd_link_hash_common) + { + unsigned int align; + + align = bfd_log2 (isym->st_value); + if (align > old_alignment + /* Permit an alignment power of zero if an alignment of one + is specified and no other alignments have been specified. */ + || (isym->st_value == 1 && old_alignment == 0)) + h->root.u.c.p->alignment_power = align; + else + h->root.u.c.p->alignment_power = old_alignment; + } + + if (is_elf_hash_table (hash_table)) + { + int old_flags; + bfd_boolean dynsym; + int new_flag; + + /* Check the alignment when a common symbol is involved. This + can change when a common symbol is overridden by a normal + definition or a common symbol is ignored due to the old + normal definition. We need to make sure the maximum + alignment is maintained. */ + if ((old_alignment || isym->st_shndx == SHN_COMMON) + && h->root.type != bfd_link_hash_common) + { + unsigned int common_align; + unsigned int normal_align; + unsigned int symbol_align; + bfd *normal_bfd; + bfd *common_bfd; + + symbol_align = ffs (h->root.u.def.value) - 1; + if (h->root.u.def.section->owner != NULL + && (h->root.u.def.section->owner->flags & DYNAMIC) == 0) + { + normal_align = h->root.u.def.section->alignment_power; + if (normal_align > symbol_align) + normal_align = symbol_align; + } + else + normal_align = symbol_align; + + if (old_alignment) + { + common_align = old_alignment; + common_bfd = old_bfd; + normal_bfd = abfd; + } + else + { + common_align = bfd_log2 (isym->st_value); + common_bfd = abfd; + normal_bfd = old_bfd; + } + + if (normal_align < common_align) + (*_bfd_error_handler) + (_("Warning: alignment %u of symbol `%s' in %s is smaller than %u in %s"), + 1 << normal_align, + name, + bfd_archive_filename (normal_bfd), + 1 << common_align, + bfd_archive_filename (common_bfd)); + } + + /* Remember the symbol size and type. */ + if (isym->st_size != 0 + && (definition || h->size == 0)) + { + if (h->size != 0 && h->size != isym->st_size && ! size_change_ok) + (*_bfd_error_handler) + (_("Warning: size of symbol `%s' changed from %lu in %s to %lu in %s"), + name, (unsigned long) h->size, + bfd_archive_filename (old_bfd), + (unsigned long) isym->st_size, + bfd_archive_filename (abfd)); + + h->size = isym->st_size; + } + + /* If this is a common symbol, then we always want H->SIZE + to be the size of the common symbol. The code just above + won't fix the size if a common symbol becomes larger. We + don't warn about a size change here, because that is + covered by --warn-common. */ + if (h->root.type == bfd_link_hash_common) + h->size = h->root.u.c.size; + + if (ELF_ST_TYPE (isym->st_info) != STT_NOTYPE + && (definition || h->type == STT_NOTYPE)) + { + if (h->type != STT_NOTYPE + && h->type != ELF_ST_TYPE (isym->st_info) + && ! type_change_ok) + (*_bfd_error_handler) + (_("Warning: type of symbol `%s' changed from %d to %d in %s"), + name, h->type, ELF_ST_TYPE (isym->st_info), + bfd_archive_filename (abfd)); + + h->type = ELF_ST_TYPE (isym->st_info); + } + + /* If st_other has a processor-specific meaning, specific + code might be needed here. We never merge the visibility + attribute with the one from a dynamic object. */ + if (bed->elf_backend_merge_symbol_attribute) + (*bed->elf_backend_merge_symbol_attribute) (h, isym, definition, + dynamic); + + if (isym->st_other != 0 && !dynamic) + { + unsigned char hvis, symvis, other, nvis; + + /* Take the balance of OTHER from the definition. */ + other = (definition ? isym->st_other : h->other); + other &= ~ ELF_ST_VISIBILITY (-1); + + /* Combine visibilities, using the most constraining one. */ + hvis = ELF_ST_VISIBILITY (h->other); + symvis = ELF_ST_VISIBILITY (isym->st_other); + if (! hvis) + nvis = symvis; + else if (! symvis) + nvis = hvis; + else + nvis = hvis < symvis ? hvis : symvis; + + h->other = other | nvis; + } + + /* Set a flag in the hash table entry indicating the type of + reference or definition we just found. Keep a count of + the number of dynamic symbols we find. A dynamic symbol + is one which is referenced or defined by both a regular + object and a shared object. */ + old_flags = h->elf_link_hash_flags; + dynsym = FALSE; + if (! dynamic) + { + if (! definition) + { + new_flag = ELF_LINK_HASH_REF_REGULAR; + if (bind != STB_WEAK) + new_flag |= ELF_LINK_HASH_REF_REGULAR_NONWEAK; + } + else + new_flag = ELF_LINK_HASH_DEF_REGULAR; + if (! info->executable + || (old_flags & (ELF_LINK_HASH_DEF_DYNAMIC + | ELF_LINK_HASH_REF_DYNAMIC)) != 0) + dynsym = TRUE; + } + else + { + if (! definition) + new_flag = ELF_LINK_HASH_REF_DYNAMIC; + else + new_flag = ELF_LINK_HASH_DEF_DYNAMIC; + if ((old_flags & (ELF_LINK_HASH_DEF_REGULAR + | ELF_LINK_HASH_REF_REGULAR)) != 0 + || (h->weakdef != NULL + && ! new_weakdef + && h->weakdef->dynindx != -1)) + dynsym = TRUE; + } + + h->elf_link_hash_flags |= new_flag; + + /* Check to see if we need to add an indirect symbol for + the default name. */ + if (definition || h->root.type == bfd_link_hash_common) + if (!_bfd_elf_add_default_symbol (abfd, info, h, name, isym, + &sec, &value, &dynsym, + override)) + goto error_free_vers; + + if (definition && !dynamic) + { + char *p = strchr (name, ELF_VER_CHR); + if (p != NULL && p[1] != ELF_VER_CHR) + { + /* Queue non-default versions so that .symver x, x@FOO + aliases can be checked. */ + if (! nondeflt_vers) + { + amt = (isymend - isym + 1) + * sizeof (struct elf_link_hash_entry *); + nondeflt_vers = bfd_malloc (amt); + } + nondeflt_vers [nondeflt_vers_cnt++] = h; + } + } + + if (dynsym && h->dynindx == -1) + { + if (! _bfd_elf_link_record_dynamic_symbol (info, h)) + goto error_free_vers; + if (h->weakdef != NULL + && ! new_weakdef + && h->weakdef->dynindx == -1) + { + if (! _bfd_elf_link_record_dynamic_symbol (info, h->weakdef)) + goto error_free_vers; + } + } + else if (dynsym && h->dynindx != -1) + /* If the symbol already has a dynamic index, but + visibility says it should not be visible, turn it into + a local symbol. */ + switch (ELF_ST_VISIBILITY (h->other)) + { + case STV_INTERNAL: + case STV_HIDDEN: + (*bed->elf_backend_hide_symbol) (info, h, TRUE); + dynsym = FALSE; + break; + } + + if (!add_needed + && definition + && dynsym + && (h->elf_link_hash_flags + & ELF_LINK_HASH_REF_REGULAR) != 0) + { + int ret; + const char *soname = elf_dt_name (abfd); + + /* A symbol from a library loaded via DT_NEEDED of some + other library is referenced by a regular object. + Add a DT_NEEDED entry for it. */ + add_needed = TRUE; + ret = elf_add_dt_needed_tag (info, soname, add_needed); + if (ret < 0) + goto error_free_vers; + + BFD_ASSERT (ret == 0); + } + } + } + + /* Now that all the symbols from this input file are created, handle + .symver foo, foo@BAR such that any relocs against foo become foo@BAR. */ + if (nondeflt_vers != NULL) + { + bfd_size_type cnt, symidx; + + for (cnt = 0; cnt < nondeflt_vers_cnt; ++cnt) + { + struct elf_link_hash_entry *h = nondeflt_vers[cnt], *hi; + char *shortname, *p; + + p = strchr (h->root.root.string, ELF_VER_CHR); + if (p == NULL + || (h->root.type != bfd_link_hash_defined + && h->root.type != bfd_link_hash_defweak)) + continue; + + amt = p - h->root.root.string; + shortname = bfd_malloc (amt + 1); + memcpy (shortname, h->root.root.string, amt); + shortname[amt] = '\0'; + + hi = (struct elf_link_hash_entry *) + bfd_link_hash_lookup (&hash_table->root, shortname, + FALSE, FALSE, FALSE); + if (hi != NULL + && hi->root.type == h->root.type + && hi->root.u.def.value == h->root.u.def.value + && hi->root.u.def.section == h->root.u.def.section) + { + (*bed->elf_backend_hide_symbol) (info, hi, TRUE); + hi->root.type = bfd_link_hash_indirect; + hi->root.u.i.link = (struct bfd_link_hash_entry *) h; + (*bed->elf_backend_copy_indirect_symbol) (bed, h, hi); + sym_hash = elf_sym_hashes (abfd); + if (sym_hash) + for (symidx = 0; symidx < extsymcount; ++symidx) + if (sym_hash[symidx] == hi) + { + sym_hash[symidx] = h; + break; + } + } + free (shortname); + } + free (nondeflt_vers); + nondeflt_vers = NULL; + } + + if (extversym != NULL) + { + free (extversym); + extversym = NULL; + } + + if (isymbuf != NULL) + free (isymbuf); + isymbuf = NULL; + + /* Now set the weakdefs field correctly for all the weak defined + symbols we found. The only way to do this is to search all the + symbols. Since we only need the information for non functions in + dynamic objects, that's the only time we actually put anything on + the list WEAKS. We need this information so that if a regular + object refers to a symbol defined weakly in a dynamic object, the + real symbol in the dynamic object is also put in the dynamic + symbols; we also must arrange for both symbols to point to the + same memory location. We could handle the general case of symbol + aliasing, but a general symbol alias can only be generated in + assembler code, handling it correctly would be very time + consuming, and other ELF linkers don't handle general aliasing + either. */ + if (weaks != NULL) + { + struct elf_link_hash_entry **hpp; + struct elf_link_hash_entry **hppend; + struct elf_link_hash_entry **sorted_sym_hash; + struct elf_link_hash_entry *h; + size_t sym_count; + + /* Since we have to search the whole symbol list for each weak + defined symbol, search time for N weak defined symbols will be + O(N^2). Binary search will cut it down to O(NlogN). */ + amt = extsymcount * sizeof (struct elf_link_hash_entry *); + sorted_sym_hash = bfd_malloc (amt); + if (sorted_sym_hash == NULL) + goto error_return; + sym_hash = sorted_sym_hash; + hpp = elf_sym_hashes (abfd); + hppend = hpp + extsymcount; + sym_count = 0; + for (; hpp < hppend; hpp++) + { + h = *hpp; + if (h != NULL + && h->root.type == bfd_link_hash_defined + && h->type != STT_FUNC) + { + *sym_hash = h; + sym_hash++; + sym_count++; + } + } + + qsort (sorted_sym_hash, sym_count, + sizeof (struct elf_link_hash_entry *), + elf_sort_symbol); + + while (weaks != NULL) + { + struct elf_link_hash_entry *hlook; + asection *slook; + bfd_vma vlook; + long ilook; + size_t i, j, idx; + + hlook = weaks; + weaks = hlook->weakdef; + hlook->weakdef = NULL; + + BFD_ASSERT (hlook->root.type == bfd_link_hash_defined + || hlook->root.type == bfd_link_hash_defweak + || hlook->root.type == bfd_link_hash_common + || hlook->root.type == bfd_link_hash_indirect); + slook = hlook->root.u.def.section; + vlook = hlook->root.u.def.value; + + ilook = -1; + i = 0; + j = sym_count; + while (i < j) + { + bfd_signed_vma vdiff; + idx = (i + j) / 2; + h = sorted_sym_hash [idx]; + vdiff = vlook - h->root.u.def.value; + if (vdiff < 0) + j = idx; + else if (vdiff > 0) + i = idx + 1; + else + { + long sdiff = slook - h->root.u.def.section; + if (sdiff < 0) + j = idx; + else if (sdiff > 0) + i = idx + 1; + else + { + ilook = idx; + break; + } + } + } + + /* We didn't find a value/section match. */ + if (ilook == -1) + continue; + + for (i = ilook; i < sym_count; i++) + { + h = sorted_sym_hash [i]; + + /* Stop if value or section doesn't match. */ + if (h->root.u.def.value != vlook + || h->root.u.def.section != slook) + break; + else if (h != hlook) + { + hlook->weakdef = h; + + /* If the weak definition is in the list of dynamic + symbols, make sure the real definition is put + there as well. */ + if (hlook->dynindx != -1 && h->dynindx == -1) + { + if (! _bfd_elf_link_record_dynamic_symbol (info, + h)) + goto error_return; + } + + /* If the real definition is in the list of dynamic + symbols, make sure the weak definition is put + there as well. If we don't do this, then the + dynamic loader might not merge the entries for the + real definition and the weak definition. */ + if (h->dynindx != -1 && hlook->dynindx == -1) + { + if (! _bfd_elf_link_record_dynamic_symbol (info, + hlook)) + goto error_return; + } + break; + } + } + } + + free (sorted_sym_hash); + } + + /* If this object is the same format as the output object, and it is + not a shared library, then let the backend look through the + relocs. + + This is required to build global offset table entries and to + arrange for dynamic relocs. It is not required for the + particular common case of linking non PIC code, even when linking + against shared libraries, but unfortunately there is no way of + knowing whether an object file has been compiled PIC or not. + Looking through the relocs is not particularly time consuming. + The problem is that we must either (1) keep the relocs in memory, + which causes the linker to require additional runtime memory or + (2) read the relocs twice from the input file, which wastes time. + This would be a good case for using mmap. + + I have no idea how to handle linking PIC code into a file of a + different format. It probably can't be done. */ + check_relocs = get_elf_backend_data (abfd)->check_relocs; + if (! dynamic + && is_elf_hash_table (hash_table) + && hash_table->root.creator == abfd->xvec + && check_relocs != NULL) + { + asection *o; + + for (o = abfd->sections; o != NULL; o = o->next) + { + Elf_Internal_Rela *internal_relocs; + bfd_boolean ok; + + if ((o->flags & SEC_RELOC) == 0 + || o->reloc_count == 0 + || ((info->strip == strip_all || info->strip == strip_debugger) + && (o->flags & SEC_DEBUGGING) != 0) + || bfd_is_abs_section (o->output_section)) + continue; + + internal_relocs = _bfd_elf_link_read_relocs (abfd, o, NULL, NULL, + info->keep_memory); + if (internal_relocs == NULL) + goto error_return; + + ok = (*check_relocs) (abfd, info, o, internal_relocs); + + if (elf_section_data (o)->relocs != internal_relocs) + free (internal_relocs); + + if (! ok) + goto error_return; + } + } + + /* If this is a non-traditional link, try to optimize the handling + of the .stab/.stabstr sections. */ + if (! dynamic + && ! info->traditional_format + && is_elf_hash_table (hash_table) + && (info->strip != strip_all && info->strip != strip_debugger)) + { + asection *stabstr; + + stabstr = bfd_get_section_by_name (abfd, ".stabstr"); + if (stabstr != NULL) + { + bfd_size_type string_offset = 0; + asection *stab; + + for (stab = abfd->sections; stab; stab = stab->next) + if (strncmp (".stab", stab->name, 5) == 0 + && (!stab->name[5] || + (stab->name[5] == '.' && ISDIGIT (stab->name[6]))) + && (stab->flags & SEC_MERGE) == 0 + && !bfd_is_abs_section (stab->output_section)) + { + struct bfd_elf_section_data *secdata; + + secdata = elf_section_data (stab); + if (! _bfd_link_section_stabs (abfd, + & hash_table->stab_info, + stab, stabstr, + &secdata->sec_info, + &string_offset)) + goto error_return; + if (secdata->sec_info) + stab->sec_info_type = ELF_INFO_TYPE_STABS; + } + } + } + + if (! info->relocatable + && ! dynamic + && is_elf_hash_table (hash_table)) + { + asection *s; + + for (s = abfd->sections; s != NULL; s = s->next) + if ((s->flags & SEC_MERGE) != 0 + && !bfd_is_abs_section (s->output_section)) + { + struct bfd_elf_section_data *secdata; + + secdata = elf_section_data (s); + if (! _bfd_merge_section (abfd, + & hash_table->merge_info, + s, &secdata->sec_info)) + goto error_return; + else if (secdata->sec_info) + s->sec_info_type = ELF_INFO_TYPE_MERGE; + } + } + + if (is_elf_hash_table (hash_table)) + { + /* Add this bfd to the loaded list. */ + struct elf_link_loaded_list *n; + + n = bfd_alloc (abfd, sizeof (struct elf_link_loaded_list)); + if (n == NULL) + goto error_return; + n->abfd = abfd; + n->next = hash_table->loaded; + hash_table->loaded = n; + } + + return TRUE; + + error_free_vers: + if (nondeflt_vers != NULL) + free (nondeflt_vers); + if (extversym != NULL) + free (extversym); + error_free_sym: + if (isymbuf != NULL) + free (isymbuf); + error_return: + return FALSE; +} + /* Add symbols from an ELF archive file to the linker hash table. We don't use _bfd_generic_link_add_archive_symbols because of a problem which arises on UnixWare. The UnixWare libc.so is an @@ -2610,9 +4170,8 @@ elf_link_is_defined_archive_symbol (bfd * abfd, carsym * symdef) Unfortunately, we do have to make multiple passes over the symbol table until nothing further is resolved. */ -bfd_boolean -_bfd_elf_link_add_archive_symbols (bfd *abfd, - struct bfd_link_info *info) +static bfd_boolean +elf_link_add_archive_symbols (bfd *abfd, struct bfd_link_info *info) { symindex c; bfd_boolean *defined = NULL; @@ -2809,3 +4368,993 @@ _bfd_elf_link_add_archive_symbols (bfd *abfd, free (included); return FALSE; } + +/* Given an ELF BFD, add symbols to the global hash table as + appropriate. */ + +bfd_boolean +bfd_elf_link_add_symbols (bfd *abfd, struct bfd_link_info *info) +{ + switch (bfd_get_format (abfd)) + { + case bfd_object: + return elf_link_add_object_symbols (abfd, info); + case bfd_archive: + return elf_link_add_archive_symbols (abfd, info); + default: + bfd_set_error (bfd_error_wrong_format); + return FALSE; + } +} + +/* This function will be called though elf_link_hash_traverse to store + all hash value of the exported symbols in an array. */ + +static bfd_boolean +elf_collect_hash_codes (struct elf_link_hash_entry *h, void *data) +{ + unsigned long **valuep = data; + const char *name; + char *p; + unsigned long ha; + char *alc = NULL; + + if (h->root.type == bfd_link_hash_warning) + h = (struct elf_link_hash_entry *) h->root.u.i.link; + + /* Ignore indirect symbols. These are added by the versioning code. */ + if (h->dynindx == -1) + return TRUE; + + name = h->root.root.string; + p = strchr (name, ELF_VER_CHR); + if (p != NULL) + { + alc = bfd_malloc (p - name + 1); + memcpy (alc, name, p - name); + alc[p - name] = '\0'; + name = alc; + } + + /* Compute the hash value. */ + ha = bfd_elf_hash (name); + + /* Store the found hash value in the array given as the argument. */ + *(*valuep)++ = ha; + + /* And store it in the struct so that we can put it in the hash table + later. */ + h->elf_hash_value = ha; + + if (alc != NULL) + free (alc); + + return TRUE; +} + +/* Array used to determine the number of hash table buckets to use + based on the number of symbols there are. If there are fewer than + 3 symbols we use 1 bucket, fewer than 17 symbols we use 3 buckets, + fewer than 37 we use 17 buckets, and so forth. We never use more + than 32771 buckets. */ + +static const size_t elf_buckets[] = +{ + 1, 3, 17, 37, 67, 97, 131, 197, 263, 521, 1031, 2053, 4099, 8209, + 16411, 32771, 0 +}; + +/* Compute bucket count for hashing table. We do not use a static set + of possible tables sizes anymore. Instead we determine for all + possible reasonable sizes of the table the outcome (i.e., the + number of collisions etc) and choose the best solution. The + weighting functions are not too simple to allow the table to grow + without bounds. Instead one of the weighting factors is the size. + Therefore the result is always a good payoff between few collisions + (= short chain lengths) and table size. */ +static size_t +compute_bucket_count (struct bfd_link_info *info) +{ + size_t dynsymcount = elf_hash_table (info)->dynsymcount; + size_t best_size = 0; + unsigned long int *hashcodes; + unsigned long int *hashcodesp; + unsigned long int i; + bfd_size_type amt; + + /* Compute the hash values for all exported symbols. At the same + time store the values in an array so that we could use them for + optimizations. */ + amt = dynsymcount; + amt *= sizeof (unsigned long int); + hashcodes = bfd_malloc (amt); + if (hashcodes == NULL) + return 0; + hashcodesp = hashcodes; + + /* Put all hash values in HASHCODES. */ + elf_link_hash_traverse (elf_hash_table (info), + elf_collect_hash_codes, &hashcodesp); + + /* We have a problem here. The following code to optimize the table + size requires an integer type with more the 32 bits. If + BFD_HOST_U_64_BIT is set we know about such a type. */ +#ifdef BFD_HOST_U_64_BIT + if (info->optimize) + { + unsigned long int nsyms = hashcodesp - hashcodes; + size_t minsize; + size_t maxsize; + BFD_HOST_U_64_BIT best_chlen = ~((BFD_HOST_U_64_BIT) 0); + unsigned long int *counts ; + bfd *dynobj = elf_hash_table (info)->dynobj; + const struct elf_backend_data *bed = get_elf_backend_data (dynobj); + + /* Possible optimization parameters: if we have NSYMS symbols we say + that the hashing table must at least have NSYMS/4 and at most + 2*NSYMS buckets. */ + minsize = nsyms / 4; + if (minsize == 0) + minsize = 1; + best_size = maxsize = nsyms * 2; + + /* Create array where we count the collisions in. We must use bfd_malloc + since the size could be large. */ + amt = maxsize; + amt *= sizeof (unsigned long int); + counts = bfd_malloc (amt); + if (counts == NULL) + { + free (hashcodes); + return 0; + } + + /* Compute the "optimal" size for the hash table. The criteria is a + minimal chain length. The minor criteria is (of course) the size + of the table. */ + for (i = minsize; i < maxsize; ++i) + { + /* Walk through the array of hashcodes and count the collisions. */ + BFD_HOST_U_64_BIT max; + unsigned long int j; + unsigned long int fact; + + memset (counts, '\0', i * sizeof (unsigned long int)); + + /* Determine how often each hash bucket is used. */ + for (j = 0; j < nsyms; ++j) + ++counts[hashcodes[j] % i]; + + /* For the weight function we need some information about the + pagesize on the target. This is information need not be 100% + accurate. Since this information is not available (so far) we + define it here to a reasonable default value. If it is crucial + to have a better value some day simply define this value. */ +# ifndef BFD_TARGET_PAGESIZE +# define BFD_TARGET_PAGESIZE (4096) +# endif + + /* We in any case need 2 + NSYMS entries for the size values and + the chains. */ + max = (2 + nsyms) * (bed->s->arch_size / 8); + +# if 1 + /* Variant 1: optimize for short chains. We add the squares + of all the chain lengths (which favors many small chain + over a few long chains). */ + for (j = 0; j < i; ++j) + max += counts[j] * counts[j]; + + /* This adds penalties for the overall size of the table. */ + fact = i / (BFD_TARGET_PAGESIZE / (bed->s->arch_size / 8)) + 1; + max *= fact * fact; +# else + /* Variant 2: Optimize a lot more for small table. Here we + also add squares of the size but we also add penalties for + empty slots (the +1 term). */ + for (j = 0; j < i; ++j) + max += (1 + counts[j]) * (1 + counts[j]); + + /* The overall size of the table is considered, but not as + strong as in variant 1, where it is squared. */ + fact = i / (BFD_TARGET_PAGESIZE / (bed->s->arch_size / 8)) + 1; + max *= fact; +# endif + + /* Compare with current best results. */ + if (max < best_chlen) + { + best_chlen = max; + best_size = i; + } + } + + free (counts); + } + else +#endif /* defined (BFD_HOST_U_64_BIT) */ + { + /* This is the fallback solution if no 64bit type is available or if we + are not supposed to spend much time on optimizations. We select the + bucket count using a fixed set of numbers. */ + for (i = 0; elf_buckets[i] != 0; i++) + { + best_size = elf_buckets[i]; + if (dynsymcount < elf_buckets[i + 1]) + break; + } + } + + /* Free the arrays we needed. */ + free (hashcodes); + + return best_size; +} + +/* Set up the sizes and contents of the ELF dynamic sections. This is + called by the ELF linker emulation before_allocation routine. We + must set the sizes of the sections before the linker sets the + addresses of the various sections. */ + +bfd_boolean +bfd_elf_size_dynamic_sections (bfd *output_bfd, + const char *soname, + const char *rpath, + const char *filter_shlib, + const char * const *auxiliary_filters, + struct bfd_link_info *info, + asection **sinterpptr, + struct bfd_elf_version_tree *verdefs) +{ + bfd_size_type soname_indx; + bfd *dynobj; + const struct elf_backend_data *bed; + struct elf_assign_sym_version_info asvinfo; + + *sinterpptr = NULL; + + soname_indx = (bfd_size_type) -1; + + if (!is_elf_hash_table (info->hash)) + return TRUE; + + if (info->execstack) + elf_tdata (output_bfd)->stack_flags = PF_R | PF_W | PF_X; + else if (info->noexecstack) + elf_tdata (output_bfd)->stack_flags = PF_R | PF_W; + else + { + bfd *inputobj; + asection *notesec = NULL; + int exec = 0; + + for (inputobj = info->input_bfds; + inputobj; + inputobj = inputobj->link_next) + { + asection *s; + + if (inputobj->flags & DYNAMIC) + continue; + s = bfd_get_section_by_name (inputobj, ".note.GNU-stack"); + if (s) + { + if (s->flags & SEC_CODE) + exec = PF_X; + notesec = s; + } + else + exec = PF_X; + } + if (notesec) + { + elf_tdata (output_bfd)->stack_flags = PF_R | PF_W | exec; + if (exec && info->relocatable + && notesec->output_section != bfd_abs_section_ptr) + notesec->output_section->flags |= SEC_CODE; + } + } + + /* Any syms created from now on start with -1 in + got.refcount/offset and plt.refcount/offset. */ + elf_hash_table (info)->init_refcount = elf_hash_table (info)->init_offset; + + /* The backend may have to create some sections regardless of whether + we're dynamic or not. */ + bed = get_elf_backend_data (output_bfd); + if (bed->elf_backend_always_size_sections + && ! (*bed->elf_backend_always_size_sections) (output_bfd, info)) + return FALSE; + + dynobj = elf_hash_table (info)->dynobj; + + /* If there were no dynamic objects in the link, there is nothing to + do here. */ + if (dynobj == NULL) + return TRUE; + + if (! _bfd_elf_maybe_strip_eh_frame_hdr (info)) + return FALSE; + + if (elf_hash_table (info)->dynamic_sections_created) + { + struct elf_info_failed eif; + struct elf_link_hash_entry *h; + asection *dynstr; + struct bfd_elf_version_tree *t; + struct bfd_elf_version_expr *d; + bfd_boolean all_defined; + + *sinterpptr = bfd_get_section_by_name (dynobj, ".interp"); + BFD_ASSERT (*sinterpptr != NULL || !info->executable); + + if (soname != NULL) + { + soname_indx = _bfd_elf_strtab_add (elf_hash_table (info)->dynstr, + soname, TRUE); + if (soname_indx == (bfd_size_type) -1 + || !_bfd_elf_add_dynamic_entry (info, DT_SONAME, soname_indx)) + return FALSE; + } + + if (info->symbolic) + { + if (!_bfd_elf_add_dynamic_entry (info, DT_SYMBOLIC, 0)) + return FALSE; + info->flags |= DF_SYMBOLIC; + } + + if (rpath != NULL) + { + bfd_size_type indx; + + indx = _bfd_elf_strtab_add (elf_hash_table (info)->dynstr, rpath, + TRUE); + if (indx == (bfd_size_type) -1 + || !_bfd_elf_add_dynamic_entry (info, DT_RPATH, indx)) + return FALSE; + + if (info->new_dtags) + { + _bfd_elf_strtab_addref (elf_hash_table (info)->dynstr, indx); + if (!_bfd_elf_add_dynamic_entry (info, DT_RUNPATH, indx)) + return FALSE; + } + } + + if (filter_shlib != NULL) + { + bfd_size_type indx; + + indx = _bfd_elf_strtab_add (elf_hash_table (info)->dynstr, + filter_shlib, TRUE); + if (indx == (bfd_size_type) -1 + || !_bfd_elf_add_dynamic_entry (info, DT_FILTER, indx)) + return FALSE; + } + + if (auxiliary_filters != NULL) + { + const char * const *p; + + for (p = auxiliary_filters; *p != NULL; p++) + { + bfd_size_type indx; + + indx = _bfd_elf_strtab_add (elf_hash_table (info)->dynstr, + *p, TRUE); + if (indx == (bfd_size_type) -1 + || !_bfd_elf_add_dynamic_entry (info, DT_AUXILIARY, indx)) + return FALSE; + } + } + + eif.info = info; + eif.verdefs = verdefs; + eif.failed = FALSE; + + /* If we are supposed to export all symbols into the dynamic symbol + table (this is not the normal case), then do so. */ + if (info->export_dynamic) + { + elf_link_hash_traverse (elf_hash_table (info), + _bfd_elf_export_symbol, + &eif); + if (eif.failed) + return FALSE; + } + + /* Make all global versions with definition. */ + for (t = verdefs; t != NULL; t = t->next) + for (d = t->globals.list; d != NULL; d = d->next) + if (!d->symver && d->symbol) + { + const char *verstr, *name; + size_t namelen, verlen, newlen; + char *newname, *p; + struct elf_link_hash_entry *newh; + + name = d->symbol; + namelen = strlen (name); + verstr = t->name; + verlen = strlen (verstr); + newlen = namelen + verlen + 3; + + newname = bfd_malloc (newlen); + if (newname == NULL) + return FALSE; + memcpy (newname, name, namelen); + + /* Check the hidden versioned definition. */ + p = newname + namelen; + *p++ = ELF_VER_CHR; + memcpy (p, verstr, verlen + 1); + newh = elf_link_hash_lookup (elf_hash_table (info), + newname, FALSE, FALSE, + FALSE); + if (newh == NULL + || (newh->root.type != bfd_link_hash_defined + && newh->root.type != bfd_link_hash_defweak)) + { + /* Check the default versioned definition. */ + *p++ = ELF_VER_CHR; + memcpy (p, verstr, verlen + 1); + newh = elf_link_hash_lookup (elf_hash_table (info), + newname, FALSE, FALSE, + FALSE); + } + free (newname); + + /* Mark this version if there is a definition and it is + not defined in a shared object. */ + if (newh != NULL + && ((newh->elf_link_hash_flags + & ELF_LINK_HASH_DEF_DYNAMIC) == 0) + && (newh->root.type == bfd_link_hash_defined + || newh->root.type == bfd_link_hash_defweak)) + d->symver = 1; + } + + /* Attach all the symbols to their version information. */ + asvinfo.output_bfd = output_bfd; + asvinfo.info = info; + asvinfo.verdefs = verdefs; + asvinfo.failed = FALSE; + + elf_link_hash_traverse (elf_hash_table (info), + _bfd_elf_link_assign_sym_version, + &asvinfo); + if (asvinfo.failed) + return FALSE; + + if (!info->allow_undefined_version) + { + /* Check if all global versions have a definition. */ + all_defined = TRUE; + for (t = verdefs; t != NULL; t = t->next) + for (d = t->globals.list; d != NULL; d = d->next) + if (!d->symver && !d->script) + { + (*_bfd_error_handler) + (_("%s: undefined version: %s"), + d->pattern, t->name); + all_defined = FALSE; + } + + if (!all_defined) + { + bfd_set_error (bfd_error_bad_value); + return FALSE; + } + } + + /* Find all symbols which were defined in a dynamic object and make + the backend pick a reasonable value for them. */ + elf_link_hash_traverse (elf_hash_table (info), + _bfd_elf_adjust_dynamic_symbol, + &eif); + if (eif.failed) + return FALSE; + + /* Add some entries to the .dynamic section. We fill in some of the + values later, in elf_bfd_final_link, but we must add the entries + now so that we know the final size of the .dynamic section. */ + + /* If there are initialization and/or finalization functions to + call then add the corresponding DT_INIT/DT_FINI entries. */ + h = (info->init_function + ? elf_link_hash_lookup (elf_hash_table (info), + info->init_function, FALSE, + FALSE, FALSE) + : NULL); + if (h != NULL + && (h->elf_link_hash_flags & (ELF_LINK_HASH_REF_REGULAR + | ELF_LINK_HASH_DEF_REGULAR)) != 0) + { + if (!_bfd_elf_add_dynamic_entry (info, DT_INIT, 0)) + return FALSE; + } + h = (info->fini_function + ? elf_link_hash_lookup (elf_hash_table (info), + info->fini_function, FALSE, + FALSE, FALSE) + : NULL); + if (h != NULL + && (h->elf_link_hash_flags & (ELF_LINK_HASH_REF_REGULAR + | ELF_LINK_HASH_DEF_REGULAR)) != 0) + { + if (!_bfd_elf_add_dynamic_entry (info, DT_FINI, 0)) + return FALSE; + } + + if (bfd_get_section_by_name (output_bfd, ".preinit_array") != NULL) + { + /* DT_PREINIT_ARRAY is not allowed in shared library. */ + if (! info->executable) + { + bfd *sub; + asection *o; + + for (sub = info->input_bfds; sub != NULL; + sub = sub->link_next) + for (o = sub->sections; o != NULL; o = o->next) + if (elf_section_data (o)->this_hdr.sh_type + == SHT_PREINIT_ARRAY) + { + (*_bfd_error_handler) + (_("%s: .preinit_array section is not allowed in DSO"), + bfd_archive_filename (sub)); + break; + } + + bfd_set_error (bfd_error_nonrepresentable_section); + return FALSE; + } + + if (!_bfd_elf_add_dynamic_entry (info, DT_PREINIT_ARRAY, 0) + || !_bfd_elf_add_dynamic_entry (info, DT_PREINIT_ARRAYSZ, 0)) + return FALSE; + } + if (bfd_get_section_by_name (output_bfd, ".init_array") != NULL) + { + if (!_bfd_elf_add_dynamic_entry (info, DT_INIT_ARRAY, 0) + || !_bfd_elf_add_dynamic_entry (info, DT_INIT_ARRAYSZ, 0)) + return FALSE; + } + if (bfd_get_section_by_name (output_bfd, ".fini_array") != NULL) + { + if (!_bfd_elf_add_dynamic_entry (info, DT_FINI_ARRAY, 0) + || !_bfd_elf_add_dynamic_entry (info, DT_FINI_ARRAYSZ, 0)) + return FALSE; + } + + dynstr = bfd_get_section_by_name (dynobj, ".dynstr"); + /* If .dynstr is excluded from the link, we don't want any of + these tags. Strictly, we should be checking each section + individually; This quick check covers for the case where + someone does a /DISCARD/ : { *(*) }. */ + if (dynstr != NULL && dynstr->output_section != bfd_abs_section_ptr) + { + bfd_size_type strsize; + + strsize = _bfd_elf_strtab_size (elf_hash_table (info)->dynstr); + if (!_bfd_elf_add_dynamic_entry (info, DT_HASH, 0) + || !_bfd_elf_add_dynamic_entry (info, DT_STRTAB, 0) + || !_bfd_elf_add_dynamic_entry (info, DT_SYMTAB, 0) + || !_bfd_elf_add_dynamic_entry (info, DT_STRSZ, strsize) + || !_bfd_elf_add_dynamic_entry (info, DT_SYMENT, + bed->s->sizeof_sym)) + return FALSE; + } + } + + /* The backend must work out the sizes of all the other dynamic + sections. */ + if (bed->elf_backend_size_dynamic_sections + && ! (*bed->elf_backend_size_dynamic_sections) (output_bfd, info)) + return FALSE; + + if (elf_hash_table (info)->dynamic_sections_created) + { + bfd_size_type dynsymcount; + asection *s; + size_t bucketcount = 0; + size_t hash_entry_size; + unsigned int dtagcount; + + /* Set up the version definition section. */ + s = bfd_get_section_by_name (dynobj, ".gnu.version_d"); + BFD_ASSERT (s != NULL); + + /* We may have created additional version definitions if we are + just linking a regular application. */ + verdefs = asvinfo.verdefs; + + /* Skip anonymous version tag. */ + if (verdefs != NULL && verdefs->vernum == 0) + verdefs = verdefs->next; + + if (verdefs == NULL) + _bfd_strip_section_from_output (info, s); + else + { + unsigned int cdefs; + bfd_size_type size; + struct bfd_elf_version_tree *t; + bfd_byte *p; + Elf_Internal_Verdef def; + Elf_Internal_Verdaux defaux; + + cdefs = 0; + size = 0; + + /* Make space for the base version. */ + size += sizeof (Elf_External_Verdef); + size += sizeof (Elf_External_Verdaux); + ++cdefs; + + for (t = verdefs; t != NULL; t = t->next) + { + struct bfd_elf_version_deps *n; + + size += sizeof (Elf_External_Verdef); + size += sizeof (Elf_External_Verdaux); + ++cdefs; + + for (n = t->deps; n != NULL; n = n->next) + size += sizeof (Elf_External_Verdaux); + } + + s->_raw_size = size; + s->contents = bfd_alloc (output_bfd, s->_raw_size); + if (s->contents == NULL && s->_raw_size != 0) + return FALSE; + + /* Fill in the version definition section. */ + + p = s->contents; + + def.vd_version = VER_DEF_CURRENT; + def.vd_flags = VER_FLG_BASE; + def.vd_ndx = 1; + def.vd_cnt = 1; + def.vd_aux = sizeof (Elf_External_Verdef); + def.vd_next = (sizeof (Elf_External_Verdef) + + sizeof (Elf_External_Verdaux)); + + if (soname_indx != (bfd_size_type) -1) + { + _bfd_elf_strtab_addref (elf_hash_table (info)->dynstr, + soname_indx); + def.vd_hash = bfd_elf_hash (soname); + defaux.vda_name = soname_indx; + } + else + { + const char *name; + bfd_size_type indx; + + name = basename (output_bfd->filename); + def.vd_hash = bfd_elf_hash (name); + indx = _bfd_elf_strtab_add (elf_hash_table (info)->dynstr, + name, FALSE); + if (indx == (bfd_size_type) -1) + return FALSE; + defaux.vda_name = indx; + } + defaux.vda_next = 0; + + _bfd_elf_swap_verdef_out (output_bfd, &def, + (Elf_External_Verdef *) p); + p += sizeof (Elf_External_Verdef); + _bfd_elf_swap_verdaux_out (output_bfd, &defaux, + (Elf_External_Verdaux *) p); + p += sizeof (Elf_External_Verdaux); + + for (t = verdefs; t != NULL; t = t->next) + { + unsigned int cdeps; + struct bfd_elf_version_deps *n; + struct elf_link_hash_entry *h; + struct bfd_link_hash_entry *bh; + + cdeps = 0; + for (n = t->deps; n != NULL; n = n->next) + ++cdeps; + + /* Add a symbol representing this version. */ + bh = NULL; + if (! (_bfd_generic_link_add_one_symbol + (info, dynobj, t->name, BSF_GLOBAL, bfd_abs_section_ptr, + 0, NULL, FALSE, + get_elf_backend_data (dynobj)->collect, &bh))) + return FALSE; + h = (struct elf_link_hash_entry *) bh; + h->elf_link_hash_flags &= ~ ELF_LINK_NON_ELF; + h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR; + h->type = STT_OBJECT; + h->verinfo.vertree = t; + + if (! _bfd_elf_link_record_dynamic_symbol (info, h)) + return FALSE; + + def.vd_version = VER_DEF_CURRENT; + def.vd_flags = 0; + if (t->globals.list == NULL + && t->locals.list == NULL + && ! t->used) + def.vd_flags |= VER_FLG_WEAK; + def.vd_ndx = t->vernum + 1; + def.vd_cnt = cdeps + 1; + def.vd_hash = bfd_elf_hash (t->name); + def.vd_aux = sizeof (Elf_External_Verdef); + def.vd_next = 0; + if (t->next != NULL) + def.vd_next = (sizeof (Elf_External_Verdef) + + (cdeps + 1) * sizeof (Elf_External_Verdaux)); + + _bfd_elf_swap_verdef_out (output_bfd, &def, + (Elf_External_Verdef *) p); + p += sizeof (Elf_External_Verdef); + + defaux.vda_name = h->dynstr_index; + _bfd_elf_strtab_addref (elf_hash_table (info)->dynstr, + h->dynstr_index); + defaux.vda_next = 0; + if (t->deps != NULL) + defaux.vda_next = sizeof (Elf_External_Verdaux); + t->name_indx = defaux.vda_name; + + _bfd_elf_swap_verdaux_out (output_bfd, &defaux, + (Elf_External_Verdaux *) p); + p += sizeof (Elf_External_Verdaux); + + for (n = t->deps; n != NULL; n = n->next) + { + if (n->version_needed == NULL) + { + /* This can happen if there was an error in the + version script. */ + defaux.vda_name = 0; + } + else + { + defaux.vda_name = n->version_needed->name_indx; + _bfd_elf_strtab_addref (elf_hash_table (info)->dynstr, + defaux.vda_name); + } + if (n->next == NULL) + defaux.vda_next = 0; + else + defaux.vda_next = sizeof (Elf_External_Verdaux); + + _bfd_elf_swap_verdaux_out (output_bfd, &defaux, + (Elf_External_Verdaux *) p); + p += sizeof (Elf_External_Verdaux); + } + } + + if (!_bfd_elf_add_dynamic_entry (info, DT_VERDEF, 0) + || !_bfd_elf_add_dynamic_entry (info, DT_VERDEFNUM, cdefs)) + return FALSE; + + elf_tdata (output_bfd)->cverdefs = cdefs; + } + + if ((info->new_dtags && info->flags) || (info->flags & DF_STATIC_TLS)) + { + if (!_bfd_elf_add_dynamic_entry (info, DT_FLAGS, info->flags)) + return FALSE; + } + else if (info->flags & DF_BIND_NOW) + { + if (!_bfd_elf_add_dynamic_entry (info, DT_BIND_NOW, 0)) + return FALSE; + } + + if (info->flags_1) + { + if (info->executable) + info->flags_1 &= ~ (DF_1_INITFIRST + | DF_1_NODELETE + | DF_1_NOOPEN); + if (!_bfd_elf_add_dynamic_entry (info, DT_FLAGS_1, info->flags_1)) + return FALSE; + } + + /* Work out the size of the version reference section. */ + + s = bfd_get_section_by_name (dynobj, ".gnu.version_r"); + BFD_ASSERT (s != NULL); + { + struct elf_find_verdep_info sinfo; + + sinfo.output_bfd = output_bfd; + sinfo.info = info; + sinfo.vers = elf_tdata (output_bfd)->cverdefs; + if (sinfo.vers == 0) + sinfo.vers = 1; + sinfo.failed = FALSE; + + elf_link_hash_traverse (elf_hash_table (info), + _bfd_elf_link_find_version_dependencies, + &sinfo); + + if (elf_tdata (output_bfd)->verref == NULL) + _bfd_strip_section_from_output (info, s); + else + { + Elf_Internal_Verneed *t; + unsigned int size; + unsigned int crefs; + bfd_byte *p; + + /* Build the version definition section. */ + size = 0; + crefs = 0; + for (t = elf_tdata (output_bfd)->verref; + t != NULL; + t = t->vn_nextref) + { + Elf_Internal_Vernaux *a; + + size += sizeof (Elf_External_Verneed); + ++crefs; + for (a = t->vn_auxptr; a != NULL; a = a->vna_nextptr) + size += sizeof (Elf_External_Vernaux); + } + + s->_raw_size = size; + s->contents = bfd_alloc (output_bfd, s->_raw_size); + if (s->contents == NULL) + return FALSE; + + p = s->contents; + for (t = elf_tdata (output_bfd)->verref; + t != NULL; + t = t->vn_nextref) + { + unsigned int caux; + Elf_Internal_Vernaux *a; + bfd_size_type indx; + + caux = 0; + for (a = t->vn_auxptr; a != NULL; a = a->vna_nextptr) + ++caux; + + t->vn_version = VER_NEED_CURRENT; + t->vn_cnt = caux; + indx = _bfd_elf_strtab_add (elf_hash_table (info)->dynstr, + elf_dt_name (t->vn_bfd) != NULL + ? elf_dt_name (t->vn_bfd) + : basename (t->vn_bfd->filename), + FALSE); + if (indx == (bfd_size_type) -1) + return FALSE; + t->vn_file = indx; + t->vn_aux = sizeof (Elf_External_Verneed); + if (t->vn_nextref == NULL) + t->vn_next = 0; + else + t->vn_next = (sizeof (Elf_External_Verneed) + + caux * sizeof (Elf_External_Vernaux)); + + _bfd_elf_swap_verneed_out (output_bfd, t, + (Elf_External_Verneed *) p); + p += sizeof (Elf_External_Verneed); + + for (a = t->vn_auxptr; a != NULL; a = a->vna_nextptr) + { + a->vna_hash = bfd_elf_hash (a->vna_nodename); + indx = _bfd_elf_strtab_add (elf_hash_table (info)->dynstr, + a->vna_nodename, FALSE); + if (indx == (bfd_size_type) -1) + return FALSE; + a->vna_name = indx; + if (a->vna_nextptr == NULL) + a->vna_next = 0; + else + a->vna_next = sizeof (Elf_External_Vernaux); + + _bfd_elf_swap_vernaux_out (output_bfd, a, + (Elf_External_Vernaux *) p); + p += sizeof (Elf_External_Vernaux); + } + } + + if (!_bfd_elf_add_dynamic_entry (info, DT_VERNEED, 0) + || !_bfd_elf_add_dynamic_entry (info, DT_VERNEEDNUM, crefs)) + return FALSE; + + elf_tdata (output_bfd)->cverrefs = crefs; + } + } + + /* Assign dynsym indicies. In a shared library we generate a + section symbol for each output section, which come first. + Next come all of the back-end allocated local dynamic syms, + followed by the rest of the global symbols. */ + + dynsymcount = _bfd_elf_link_renumber_dynsyms (output_bfd, info); + + /* Work out the size of the symbol version section. */ + s = bfd_get_section_by_name (dynobj, ".gnu.version"); + BFD_ASSERT (s != NULL); + if (dynsymcount == 0 + || (verdefs == NULL && elf_tdata (output_bfd)->verref == NULL)) + { + _bfd_strip_section_from_output (info, s); + /* The DYNSYMCOUNT might have changed if we were going to + output a dynamic symbol table entry for S. */ + dynsymcount = _bfd_elf_link_renumber_dynsyms (output_bfd, info); + } + else + { + s->_raw_size = dynsymcount * sizeof (Elf_External_Versym); + s->contents = bfd_zalloc (output_bfd, s->_raw_size); + if (s->contents == NULL) + return FALSE; + + if (!_bfd_elf_add_dynamic_entry (info, DT_VERSYM, 0)) + return FALSE; + } + + /* Set the size of the .dynsym and .hash sections. We counted + the number of dynamic symbols in elf_link_add_object_symbols. + We will build the contents of .dynsym and .hash when we build + the final symbol table, because until then we do not know the + correct value to give the symbols. We built the .dynstr + section as we went along in elf_link_add_object_symbols. */ + s = bfd_get_section_by_name (dynobj, ".dynsym"); + BFD_ASSERT (s != NULL); + s->_raw_size = dynsymcount * bed->s->sizeof_sym; + s->contents = bfd_alloc (output_bfd, s->_raw_size); + if (s->contents == NULL && s->_raw_size != 0) + return FALSE; + + if (dynsymcount != 0) + { + Elf_Internal_Sym isym; + + /* The first entry in .dynsym is a dummy symbol. */ + isym.st_value = 0; + isym.st_size = 0; + isym.st_name = 0; + isym.st_info = 0; + isym.st_other = 0; + isym.st_shndx = 0; + bed->s->swap_symbol_out (output_bfd, &isym, s->contents, 0); + } + + /* Compute the size of the hashing table. As a side effect this + computes the hash values for all the names we export. */ + bucketcount = compute_bucket_count (info); + + s = bfd_get_section_by_name (dynobj, ".hash"); + BFD_ASSERT (s != NULL); + hash_entry_size = elf_section_data (s)->this_hdr.sh_entsize; + s->_raw_size = ((2 + bucketcount + dynsymcount) * hash_entry_size); + s->contents = bfd_zalloc (output_bfd, s->_raw_size); + if (s->contents == NULL) + return FALSE; + + bfd_put (8 * hash_entry_size, output_bfd, bucketcount, s->contents); + bfd_put (8 * hash_entry_size, output_bfd, dynsymcount, + s->contents + hash_entry_size); + + elf_hash_table (info)->bucketcount = bucketcount; + + s = bfd_get_section_by_name (dynobj, ".dynstr"); + BFD_ASSERT (s != NULL); + + elf_finalize_dynstr (output_bfd, info); + + s->_raw_size = _bfd_elf_strtab_size (elf_hash_table (info)->dynstr); + + for (dtagcount = 0; dtagcount <= info->spare_dynamic_tags; ++dtagcount) + if (!_bfd_elf_add_dynamic_entry (info, DT_NULL, 0)) + return FALSE; + } + + return TRUE; +} diff --git a/bfd/elflink.h b/bfd/elflink.h index adecd808cf0..de477dfbd27 100644 --- a/bfd/elflink.h +++ b/bfd/elflink.h @@ -20,2504 +20,8 @@ /* ELF linker code. */ -#include "safe-ctype.h" - -static bfd_boolean elf_link_add_object_symbols (bfd *, struct bfd_link_info *); -static bfd_boolean elf_finalize_dynstr (bfd *, struct bfd_link_info *); -static bfd_boolean elf_collect_hash_codes (struct elf_link_hash_entry *, - void *); static bfd_boolean elf_section_ignore_discarded_relocs (asection *); -/* Given an ELF BFD, add symbols to the global hash table as - appropriate. */ - -bfd_boolean -elf_bfd_link_add_symbols (bfd *abfd, struct bfd_link_info *info) -{ - switch (bfd_get_format (abfd)) - { - case bfd_object: - return elf_link_add_object_symbols (abfd, info); - case bfd_archive: - return _bfd_elf_link_add_archive_symbols (abfd, info); - default: - bfd_set_error (bfd_error_wrong_format); - return FALSE; - } -} - -/* Sort symbol by value and section. */ -static int -sort_symbol (const void *arg1, const void *arg2) -{ - const struct elf_link_hash_entry *h1 - = *(const struct elf_link_hash_entry **) arg1; - const struct elf_link_hash_entry *h2 - = *(const struct elf_link_hash_entry **) arg2; - bfd_signed_vma vdiff = h1->root.u.def.value - h2->root.u.def.value; - - if (vdiff) - return vdiff > 0 ? 1 : -1; - else - { - long sdiff = h1->root.u.def.section - h2->root.u.def.section; - if (sdiff) - return sdiff > 0 ? 1 : -1; - else - return 0; - } -} - -/* Add a DT_NEEDED entry for this dynamic object. Returns -1 on error, - 1 if a DT_NEEDED tag already exists, and 0 on success. */ - -static int -add_dt_needed_tag (struct bfd_link_info *info, const char *soname, - bfd_boolean do_it) -{ - struct elf_link_hash_table *hash_table; - bfd_size_type oldsize; - bfd_size_type strindex; - - hash_table = elf_hash_table (info); - oldsize = _bfd_elf_strtab_size (hash_table->dynstr); - strindex = _bfd_elf_strtab_add (hash_table->dynstr, soname, FALSE); - if (strindex == (bfd_size_type) -1) - return -1; - - if (oldsize == _bfd_elf_strtab_size (hash_table->dynstr)) - { - asection *sdyn; - Elf_External_Dyn *dyncon, *dynconend; - - sdyn = bfd_get_section_by_name (hash_table->dynobj, ".dynamic"); - BFD_ASSERT (sdyn != NULL); - - dyncon = (Elf_External_Dyn *) sdyn->contents; - dynconend = (Elf_External_Dyn *) (sdyn->contents + sdyn->_raw_size); - for (; dyncon < dynconend; dyncon++) - { - Elf_Internal_Dyn dyn; - - elf_swap_dyn_in (hash_table->dynobj, dyncon, & dyn); - if (dyn.d_tag == DT_NEEDED - && dyn.d_un.d_val == strindex) - { - _bfd_elf_strtab_delref (hash_table->dynstr, strindex); - return 1; - } - } - } - - if (do_it) - { - if (! elf_add_dynamic_entry (info, DT_NEEDED, strindex)) - return -1; - } - else - /* We were just checking for existence of the tag. */ - _bfd_elf_strtab_delref (hash_table->dynstr, strindex); - - return 0; -} - -/* Add symbols from an ELF object file to the linker hash table. */ - -static bfd_boolean -elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info) -{ - bfd_boolean (*add_symbol_hook) - (bfd *, struct bfd_link_info *, const Elf_Internal_Sym *, - const char **, flagword *, asection **, bfd_vma *); - bfd_boolean (*check_relocs) - (bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *); - bfd_boolean collect; - Elf_Internal_Shdr *hdr; - bfd_size_type symcount; - bfd_size_type extsymcount; - bfd_size_type extsymoff; - struct elf_link_hash_entry **sym_hash; - bfd_boolean dynamic; - Elf_External_Versym *extversym = NULL; - Elf_External_Versym *ever; - struct elf_link_hash_entry *weaks; - struct elf_link_hash_entry **nondeflt_vers = NULL; - bfd_size_type nondeflt_vers_cnt = 0; - Elf_Internal_Sym *isymbuf = NULL; - Elf_Internal_Sym *isym; - Elf_Internal_Sym *isymend; - const struct elf_backend_data *bed; - bfd_boolean add_needed; - struct elf_link_hash_table * hash_table; - bfd_size_type amt; - - hash_table = elf_hash_table (info); - - bed = get_elf_backend_data (abfd); - add_symbol_hook = bed->elf_add_symbol_hook; - collect = bed->collect; - - if ((abfd->flags & DYNAMIC) == 0) - dynamic = FALSE; - else - { - dynamic = TRUE; - - /* You can't use -r against a dynamic object. Also, there's no - hope of using a dynamic object which does not exactly match - the format of the output file. */ - if (info->relocatable - || !is_elf_hash_table (hash_table) - || hash_table->root.creator != abfd->xvec) - { - bfd_set_error (bfd_error_invalid_operation); - goto error_return; - } - } - - /* As a GNU extension, any input sections which are named - .gnu.warning.SYMBOL are treated as warning symbols for the given - symbol. This differs from .gnu.warning sections, which generate - warnings when they are included in an output file. */ - if (info->executable) - { - asection *s; - - for (s = abfd->sections; s != NULL; s = s->next) - { - const char *name; - - name = bfd_get_section_name (abfd, s); - if (strncmp (name, ".gnu.warning.", sizeof ".gnu.warning." - 1) == 0) - { - char *msg; - bfd_size_type sz; - bfd_size_type prefix_len; - const char * gnu_warning_prefix = _("warning: "); - - name += sizeof ".gnu.warning." - 1; - - /* If this is a shared object, then look up the symbol - in the hash table. If it is there, and it is already - been defined, then we will not be using the entry - from this shared object, so we don't need to warn. - FIXME: If we see the definition in a regular object - later on, we will warn, but we shouldn't. The only - fix is to keep track of what warnings we are supposed - to emit, and then handle them all at the end of the - link. */ - if (dynamic) - { - struct elf_link_hash_entry *h; - - h = elf_link_hash_lookup (hash_table, name, - FALSE, FALSE, TRUE); - - /* FIXME: What about bfd_link_hash_common? */ - if (h != NULL - && (h->root.type == bfd_link_hash_defined - || h->root.type == bfd_link_hash_defweak)) - { - /* We don't want to issue this warning. Clobber - the section size so that the warning does not - get copied into the output file. */ - s->_raw_size = 0; - continue; - } - } - - sz = bfd_section_size (abfd, s); - prefix_len = strlen (gnu_warning_prefix); - msg = bfd_alloc (abfd, prefix_len + sz + 1); - if (msg == NULL) - goto error_return; - - strcpy (msg, gnu_warning_prefix); - if (! bfd_get_section_contents (abfd, s, msg + prefix_len, 0, sz)) - goto error_return; - - msg[prefix_len + sz] = '\0'; - - if (! (_bfd_generic_link_add_one_symbol - (info, abfd, name, BSF_WARNING, s, 0, msg, - FALSE, collect, NULL))) - goto error_return; - - if (! info->relocatable) - { - /* Clobber the section size so that the warning does - not get copied into the output file. */ - s->_raw_size = 0; - } - } - } - } - - add_needed = TRUE; - if (! dynamic) - { - /* If we are creating a shared library, create all the dynamic - sections immediately. We need to attach them to something, - so we attach them to this BFD, provided it is the right - format. FIXME: If there are no input BFD's of the same - format as the output, we can't make a shared library. */ - if (info->shared - && is_elf_hash_table (hash_table) - && hash_table->root.creator == abfd->xvec - && ! hash_table->dynamic_sections_created) - { - if (! _bfd_elf_link_create_dynamic_sections (abfd, info)) - goto error_return; - } - } - else if (!is_elf_hash_table (hash_table)) - goto error_return; - else - { - asection *s; - const char *soname = NULL; - struct bfd_link_needed_list *rpath = NULL, *runpath = NULL; - int ret; - - /* ld --just-symbols and dynamic objects don't mix very well. - Test for --just-symbols by looking at info set up by - _bfd_elf_link_just_syms. */ - if ((s = abfd->sections) != NULL - && s->sec_info_type == ELF_INFO_TYPE_JUST_SYMS) - goto error_return; - - /* If this dynamic lib was specified on the command line with - --as-needed in effect, then we don't want to add a DT_NEEDED - tag unless the lib is actually used. Similary for libs brought - in by another lib's DT_NEEDED. */ - add_needed = elf_dyn_lib_class (abfd) == DYN_NORMAL; - - s = bfd_get_section_by_name (abfd, ".dynamic"); - if (s != NULL) - { - Elf_External_Dyn *dynbuf = NULL; - Elf_External_Dyn *extdyn; - Elf_External_Dyn *extdynend; - int elfsec; - unsigned long shlink; - - dynbuf = bfd_malloc (s->_raw_size); - if (dynbuf == NULL) - goto error_return; - - if (! bfd_get_section_contents (abfd, s, dynbuf, 0, s->_raw_size)) - goto error_free_dyn; - - elfsec = _bfd_elf_section_from_bfd_section (abfd, s); - if (elfsec == -1) - goto error_free_dyn; - shlink = elf_elfsections (abfd)[elfsec]->sh_link; - - extdyn = dynbuf; - extdynend = extdyn + s->_raw_size / sizeof (Elf_External_Dyn); - for (; extdyn < extdynend; extdyn++) - { - Elf_Internal_Dyn dyn; - - elf_swap_dyn_in (abfd, extdyn, &dyn); - if (dyn.d_tag == DT_SONAME) - { - unsigned int tagv = dyn.d_un.d_val; - soname = bfd_elf_string_from_elf_section (abfd, shlink, tagv); - if (soname == NULL) - goto error_free_dyn; - } - if (dyn.d_tag == DT_NEEDED) - { - struct bfd_link_needed_list *n, **pn; - char *fnm, *anm; - unsigned int tagv = dyn.d_un.d_val; - - amt = sizeof (struct bfd_link_needed_list); - n = bfd_alloc (abfd, amt); - fnm = bfd_elf_string_from_elf_section (abfd, shlink, tagv); - if (n == NULL || fnm == NULL) - goto error_free_dyn; - amt = strlen (fnm) + 1; - anm = bfd_alloc (abfd, amt); - if (anm == NULL) - goto error_free_dyn; - memcpy (anm, fnm, amt); - n->name = anm; - n->by = abfd; - n->next = NULL; - for (pn = & hash_table->needed; - *pn != NULL; - pn = &(*pn)->next) - ; - *pn = n; - } - if (dyn.d_tag == DT_RUNPATH) - { - struct bfd_link_needed_list *n, **pn; - char *fnm, *anm; - unsigned int tagv = dyn.d_un.d_val; - - amt = sizeof (struct bfd_link_needed_list); - n = bfd_alloc (abfd, amt); - fnm = bfd_elf_string_from_elf_section (abfd, shlink, tagv); - if (n == NULL || fnm == NULL) - goto error_free_dyn; - amt = strlen (fnm) + 1; - anm = bfd_alloc (abfd, amt); - if (anm == NULL) - goto error_free_dyn; - memcpy (anm, fnm, amt); - n->name = anm; - n->by = abfd; - n->next = NULL; - for (pn = & runpath; - *pn != NULL; - pn = &(*pn)->next) - ; - *pn = n; - } - /* Ignore DT_RPATH if we have seen DT_RUNPATH. */ - if (!runpath && dyn.d_tag == DT_RPATH) - { - struct bfd_link_needed_list *n, **pn; - char *fnm, *anm; - unsigned int tagv = dyn.d_un.d_val; - - amt = sizeof (struct bfd_link_needed_list); - n = bfd_alloc (abfd, amt); - fnm = bfd_elf_string_from_elf_section (abfd, shlink, tagv); - if (n == NULL || fnm == NULL) - goto error_free_dyn; - amt = strlen (fnm) + 1; - anm = bfd_alloc (abfd, amt); - if (anm == NULL) - { - error_free_dyn: - free (dynbuf); - goto error_return; - } - memcpy (anm, fnm, amt); - n->name = anm; - n->by = abfd; - n->next = NULL; - for (pn = & rpath; - *pn != NULL; - pn = &(*pn)->next) - ; - *pn = n; - } - } - - free (dynbuf); - } - - /* DT_RUNPATH overrides DT_RPATH. Do _NOT_ bfd_release, as that - frees all more recently bfd_alloc'd blocks as well. */ - if (runpath) - rpath = runpath; - - if (rpath) - { - struct bfd_link_needed_list **pn; - for (pn = & hash_table->runpath; - *pn != NULL; - pn = &(*pn)->next) - ; - *pn = rpath; - } - - /* We do not want to include any of the sections in a dynamic - object in the output file. We hack by simply clobbering the - list of sections in the BFD. This could be handled more - cleanly by, say, a new section flag; the existing - SEC_NEVER_LOAD flag is not the one we want, because that one - still implies that the section takes up space in the output - file. */ - bfd_section_list_clear (abfd); - - /* If this is the first dynamic object found in the link, create - the special sections required for dynamic linking. */ - if (! _bfd_elf_link_create_dynamic_sections (abfd, info)) - goto error_return; - - /* Find the name to use in a DT_NEEDED entry that refers to this - object. If the object has a DT_SONAME entry, we use it. - Otherwise, if the generic linker stuck something in - elf_dt_name, we use that. Otherwise, we just use the file - name. */ - if (soname == NULL || *soname == '\0') - { - soname = elf_dt_name (abfd); - if (soname == NULL || *soname == '\0') - soname = bfd_get_filename (abfd); - } - - /* Save the SONAME because sometimes the linker emulation code - will need to know it. */ - elf_dt_name (abfd) = soname; - - ret = add_dt_needed_tag (info, soname, add_needed); - if (ret < 0) - goto error_return; - - /* If we have already included this dynamic object in the - link, just ignore it. There is no reason to include a - particular dynamic object more than once. */ - if (ret > 0) - return TRUE; - } - - /* If this is a dynamic object, we always link against the .dynsym - symbol table, not the .symtab symbol table. The dynamic linker - will only see the .dynsym symbol table, so there is no reason to - look at .symtab for a dynamic object. */ - - if (! dynamic || elf_dynsymtab (abfd) == 0) - hdr = &elf_tdata (abfd)->symtab_hdr; - else - hdr = &elf_tdata (abfd)->dynsymtab_hdr; - - symcount = hdr->sh_size / sizeof (Elf_External_Sym); - - /* The sh_info field of the symtab header tells us where the - external symbols start. We don't care about the local symbols at - this point. */ - if (elf_bad_symtab (abfd)) - { - extsymcount = symcount; - extsymoff = 0; - } - else - { - extsymcount = symcount - hdr->sh_info; - extsymoff = hdr->sh_info; - } - - sym_hash = NULL; - if (extsymcount != 0) - { - isymbuf = bfd_elf_get_elf_syms (abfd, hdr, extsymcount, extsymoff, - NULL, NULL, NULL); - if (isymbuf == NULL) - goto error_return; - - /* We store a pointer to the hash table entry for each external - symbol. */ - amt = extsymcount * sizeof (struct elf_link_hash_entry *); - sym_hash = bfd_alloc (abfd, amt); - if (sym_hash == NULL) - goto error_free_sym; - elf_sym_hashes (abfd) = sym_hash; - } - - if (dynamic) - { - /* Read in any version definitions. */ - if (! _bfd_elf_slurp_version_tables (abfd)) - goto error_free_sym; - - /* Read in the symbol versions, but don't bother to convert them - to internal format. */ - if (elf_dynversym (abfd) != 0) - { - Elf_Internal_Shdr *versymhdr; - - versymhdr = &elf_tdata (abfd)->dynversym_hdr; - extversym = bfd_malloc (versymhdr->sh_size); - if (extversym == NULL) - goto error_free_sym; - amt = versymhdr->sh_size; - if (bfd_seek (abfd, versymhdr->sh_offset, SEEK_SET) != 0 - || bfd_bread (extversym, amt, abfd) != amt) - goto error_free_vers; - } - } - - weaks = NULL; - - ever = extversym != NULL ? extversym + extsymoff : NULL; - for (isym = isymbuf, isymend = isymbuf + extsymcount; - isym < isymend; - isym++, sym_hash++, ever = (ever != NULL ? ever + 1 : NULL)) - { - int bind; - bfd_vma value; - asection *sec; - flagword flags; - const char *name; - struct elf_link_hash_entry *h; - bfd_boolean definition; - bfd_boolean size_change_ok; - bfd_boolean type_change_ok; - bfd_boolean new_weakdef; - bfd_boolean override; - unsigned int old_alignment; - bfd *old_bfd; - - override = FALSE; - - flags = BSF_NO_FLAGS; - sec = NULL; - value = isym->st_value; - *sym_hash = NULL; - - bind = ELF_ST_BIND (isym->st_info); - if (bind == STB_LOCAL) - { - /* This should be impossible, since ELF requires that all - global symbols follow all local symbols, and that sh_info - point to the first global symbol. Unfortunately, Irix 5 - screws this up. */ - continue; - } - else if (bind == STB_GLOBAL) - { - if (isym->st_shndx != SHN_UNDEF - && isym->st_shndx != SHN_COMMON) - flags = BSF_GLOBAL; - } - else if (bind == STB_WEAK) - flags = BSF_WEAK; - else - { - /* Leave it up to the processor backend. */ - } - - if (isym->st_shndx == SHN_UNDEF) - sec = bfd_und_section_ptr; - else if (isym->st_shndx < SHN_LORESERVE || isym->st_shndx > SHN_HIRESERVE) - { - sec = section_from_elf_index (abfd, isym->st_shndx); - if (sec == NULL) - sec = bfd_abs_section_ptr; - else if ((abfd->flags & (EXEC_P | DYNAMIC)) != 0) - value -= sec->vma; - } - else if (isym->st_shndx == SHN_ABS) - sec = bfd_abs_section_ptr; - else if (isym->st_shndx == SHN_COMMON) - { - sec = bfd_com_section_ptr; - /* What ELF calls the size we call the value. What ELF - calls the value we call the alignment. */ - value = isym->st_size; - } - else - { - /* Leave it up to the processor backend. */ - } - - name = bfd_elf_string_from_elf_section (abfd, hdr->sh_link, - isym->st_name); - if (name == NULL) - goto error_free_vers; - - if (isym->st_shndx == SHN_COMMON - && ELF_ST_TYPE (isym->st_info) == STT_TLS) - { - asection *tcomm = bfd_get_section_by_name (abfd, ".tcommon"); - - if (tcomm == NULL) - { - tcomm = bfd_make_section (abfd, ".tcommon"); - if (tcomm == NULL - || !bfd_set_section_flags (abfd, tcomm, (SEC_ALLOC - | SEC_IS_COMMON - | SEC_LINKER_CREATED - | SEC_THREAD_LOCAL))) - goto error_free_vers; - } - sec = tcomm; - } - else if (add_symbol_hook) - { - if (! (*add_symbol_hook) (abfd, info, isym, &name, &flags, &sec, - &value)) - goto error_free_vers; - - /* The hook function sets the name to NULL if this symbol - should be skipped for some reason. */ - if (name == NULL) - continue; - } - - /* Sanity check that all possibilities were handled. */ - if (sec == NULL) - { - bfd_set_error (bfd_error_bad_value); - goto error_free_vers; - } - - if (bfd_is_und_section (sec) - || bfd_is_com_section (sec)) - definition = FALSE; - else - definition = TRUE; - - size_change_ok = FALSE; - type_change_ok = get_elf_backend_data (abfd)->type_change_ok; - old_alignment = 0; - old_bfd = NULL; - - if (is_elf_hash_table (hash_table)) - { - Elf_Internal_Versym iver; - unsigned int vernum = 0; - bfd_boolean skip; - - if (ever != NULL) - { - _bfd_elf_swap_versym_in (abfd, ever, &iver); - vernum = iver.vs_vers & VERSYM_VERSION; - - /* If this is a hidden symbol, or if it is not version - 1, we append the version name to the symbol name. - However, we do not modify a non-hidden absolute - symbol, because it might be the version symbol - itself. FIXME: What if it isn't? */ - if ((iver.vs_vers & VERSYM_HIDDEN) != 0 - || (vernum > 1 && ! bfd_is_abs_section (sec))) - { - const char *verstr; - size_t namelen, verlen, newlen; - char *newname, *p; - - if (isym->st_shndx != SHN_UNDEF) - { - if (vernum > elf_tdata (abfd)->dynverdef_hdr.sh_info) - { - (*_bfd_error_handler) - (_("%s: %s: invalid version %u (max %d)"), - bfd_archive_filename (abfd), name, vernum, - elf_tdata (abfd)->dynverdef_hdr.sh_info); - bfd_set_error (bfd_error_bad_value); - goto error_free_vers; - } - else if (vernum > 1) - verstr = - elf_tdata (abfd)->verdef[vernum - 1].vd_nodename; - else - verstr = ""; - } - else - { - /* We cannot simply test for the number of - entries in the VERNEED section since the - numbers for the needed versions do not start - at 0. */ - Elf_Internal_Verneed *t; - - verstr = NULL; - for (t = elf_tdata (abfd)->verref; - t != NULL; - t = t->vn_nextref) - { - Elf_Internal_Vernaux *a; - - for (a = t->vn_auxptr; a != NULL; a = a->vna_nextptr) - { - if (a->vna_other == vernum) - { - verstr = a->vna_nodename; - break; - } - } - if (a != NULL) - break; - } - if (verstr == NULL) - { - (*_bfd_error_handler) - (_("%s: %s: invalid needed version %d"), - bfd_archive_filename (abfd), name, vernum); - bfd_set_error (bfd_error_bad_value); - goto error_free_vers; - } - } - - namelen = strlen (name); - verlen = strlen (verstr); - newlen = namelen + verlen + 2; - if ((iver.vs_vers & VERSYM_HIDDEN) == 0 - && isym->st_shndx != SHN_UNDEF) - ++newlen; - - newname = bfd_alloc (abfd, newlen); - if (newname == NULL) - goto error_free_vers; - memcpy (newname, name, namelen); - p = newname + namelen; - *p++ = ELF_VER_CHR; - /* If this is a defined non-hidden version symbol, - we add another @ to the name. This indicates the - default version of the symbol. */ - if ((iver.vs_vers & VERSYM_HIDDEN) == 0 - && isym->st_shndx != SHN_UNDEF) - *p++ = ELF_VER_CHR; - memcpy (p, verstr, verlen + 1); - - name = newname; - } - } - - if (!_bfd_elf_merge_symbol (abfd, info, name, isym, &sec, &value, - sym_hash, &skip, &override, - &type_change_ok, &size_change_ok)) - goto error_free_vers; - - if (skip) - continue; - - if (override) - definition = FALSE; - - h = *sym_hash; - while (h->root.type == bfd_link_hash_indirect - || h->root.type == bfd_link_hash_warning) - h = (struct elf_link_hash_entry *) h->root.u.i.link; - - /* Remember the old alignment if this is a common symbol, so - that we don't reduce the alignment later on. We can't - check later, because _bfd_generic_link_add_one_symbol - will set a default for the alignment which we want to - override. We also remember the old bfd where the existing - definition comes from. */ - switch (h->root.type) - { - default: - break; - - case bfd_link_hash_defined: - case bfd_link_hash_defweak: - old_bfd = h->root.u.def.section->owner; - break; - - case bfd_link_hash_common: - old_bfd = h->root.u.c.p->section->owner; - old_alignment = h->root.u.c.p->alignment_power; - break; - } - - if (elf_tdata (abfd)->verdef != NULL - && ! override - && vernum > 1 - && definition) - h->verinfo.verdef = &elf_tdata (abfd)->verdef[vernum - 1]; - } - - if (! (_bfd_generic_link_add_one_symbol - (info, abfd, name, flags, sec, value, NULL, FALSE, collect, - (struct bfd_link_hash_entry **) sym_hash))) - goto error_free_vers; - - h = *sym_hash; - while (h->root.type == bfd_link_hash_indirect - || h->root.type == bfd_link_hash_warning) - h = (struct elf_link_hash_entry *) h->root.u.i.link; - *sym_hash = h; - - new_weakdef = FALSE; - if (dynamic - && definition - && (flags & BSF_WEAK) != 0 - && ELF_ST_TYPE (isym->st_info) != STT_FUNC - && is_elf_hash_table (hash_table) - && h->weakdef == NULL) - { - /* Keep a list of all weak defined non function symbols from - a dynamic object, using the weakdef field. Later in this - function we will set the weakdef field to the correct - value. We only put non-function symbols from dynamic - objects on this list, because that happens to be the only - time we need to know the normal symbol corresponding to a - weak symbol, and the information is time consuming to - figure out. If the weakdef field is not already NULL, - then this symbol was already defined by some previous - dynamic object, and we will be using that previous - definition anyhow. */ - - h->weakdef = weaks; - weaks = h; - new_weakdef = TRUE; - } - - /* Set the alignment of a common symbol. */ - if (isym->st_shndx == SHN_COMMON - && h->root.type == bfd_link_hash_common) - { - unsigned int align; - - align = bfd_log2 (isym->st_value); - if (align > old_alignment - /* Permit an alignment power of zero if an alignment of one - is specified and no other alignments have been specified. */ - || (isym->st_value == 1 && old_alignment == 0)) - h->root.u.c.p->alignment_power = align; - else - h->root.u.c.p->alignment_power = old_alignment; - } - - if (is_elf_hash_table (hash_table)) - { - int old_flags; - bfd_boolean dynsym; - int new_flag; - - /* Check the alignment when a common symbol is involved. This - can change when a common symbol is overridden by a normal - definition or a common symbol is ignored due to the old - normal definition. We need to make sure the maximum - alignment is maintained. */ - if ((old_alignment || isym->st_shndx == SHN_COMMON) - && h->root.type != bfd_link_hash_common) - { - unsigned int common_align; - unsigned int normal_align; - unsigned int symbol_align; - bfd *normal_bfd; - bfd *common_bfd; - - symbol_align = ffs (h->root.u.def.value) - 1; - if (h->root.u.def.section->owner != NULL - && (h->root.u.def.section->owner->flags & DYNAMIC) == 0) - { - normal_align = h->root.u.def.section->alignment_power; - if (normal_align > symbol_align) - normal_align = symbol_align; - } - else - normal_align = symbol_align; - - if (old_alignment) - { - common_align = old_alignment; - common_bfd = old_bfd; - normal_bfd = abfd; - } - else - { - common_align = bfd_log2 (isym->st_value); - common_bfd = abfd; - normal_bfd = old_bfd; - } - - if (normal_align < common_align) - (*_bfd_error_handler) - (_("Warning: alignment %u of symbol `%s' in %s is smaller than %u in %s"), - 1 << normal_align, - name, - bfd_archive_filename (normal_bfd), - 1 << common_align, - bfd_archive_filename (common_bfd)); - } - - /* Remember the symbol size and type. */ - if (isym->st_size != 0 - && (definition || h->size == 0)) - { - if (h->size != 0 && h->size != isym->st_size && ! size_change_ok) - (*_bfd_error_handler) - (_("Warning: size of symbol `%s' changed from %lu in %s to %lu in %s"), - name, (unsigned long) h->size, - bfd_archive_filename (old_bfd), - (unsigned long) isym->st_size, - bfd_archive_filename (abfd)); - - h->size = isym->st_size; - } - - /* If this is a common symbol, then we always want H->SIZE - to be the size of the common symbol. The code just above - won't fix the size if a common symbol becomes larger. We - don't warn about a size change here, because that is - covered by --warn-common. */ - if (h->root.type == bfd_link_hash_common) - h->size = h->root.u.c.size; - - if (ELF_ST_TYPE (isym->st_info) != STT_NOTYPE - && (definition || h->type == STT_NOTYPE)) - { - if (h->type != STT_NOTYPE - && h->type != ELF_ST_TYPE (isym->st_info) - && ! type_change_ok) - (*_bfd_error_handler) - (_("Warning: type of symbol `%s' changed from %d to %d in %s"), - name, h->type, ELF_ST_TYPE (isym->st_info), - bfd_archive_filename (abfd)); - - h->type = ELF_ST_TYPE (isym->st_info); - } - - /* If st_other has a processor-specific meaning, specific - code might be needed here. We never merge the visibility - attribute with the one from a dynamic object. */ - if (bed->elf_backend_merge_symbol_attribute) - (*bed->elf_backend_merge_symbol_attribute) (h, isym, definition, - dynamic); - - if (isym->st_other != 0 && !dynamic) - { - unsigned char hvis, symvis, other, nvis; - - /* Take the balance of OTHER from the definition. */ - other = (definition ? isym->st_other : h->other); - other &= ~ ELF_ST_VISIBILITY (-1); - - /* Combine visibilities, using the most constraining one. */ - hvis = ELF_ST_VISIBILITY (h->other); - symvis = ELF_ST_VISIBILITY (isym->st_other); - if (! hvis) - nvis = symvis; - else if (! symvis) - nvis = hvis; - else - nvis = hvis < symvis ? hvis : symvis; - - h->other = other | nvis; - } - - /* Set a flag in the hash table entry indicating the type of - reference or definition we just found. Keep a count of - the number of dynamic symbols we find. A dynamic symbol - is one which is referenced or defined by both a regular - object and a shared object. */ - old_flags = h->elf_link_hash_flags; - dynsym = FALSE; - if (! dynamic) - { - if (! definition) - { - new_flag = ELF_LINK_HASH_REF_REGULAR; - if (bind != STB_WEAK) - new_flag |= ELF_LINK_HASH_REF_REGULAR_NONWEAK; - } - else - new_flag = ELF_LINK_HASH_DEF_REGULAR; - if (! info->executable - || (old_flags & (ELF_LINK_HASH_DEF_DYNAMIC - | ELF_LINK_HASH_REF_DYNAMIC)) != 0) - dynsym = TRUE; - } - else - { - if (! definition) - new_flag = ELF_LINK_HASH_REF_DYNAMIC; - else - new_flag = ELF_LINK_HASH_DEF_DYNAMIC; - if ((old_flags & (ELF_LINK_HASH_DEF_REGULAR - | ELF_LINK_HASH_REF_REGULAR)) != 0 - || (h->weakdef != NULL - && ! new_weakdef - && h->weakdef->dynindx != -1)) - dynsym = TRUE; - } - - h->elf_link_hash_flags |= new_flag; - - /* Check to see if we need to add an indirect symbol for - the default name. */ - if (definition || h->root.type == bfd_link_hash_common) - if (!_bfd_elf_add_default_symbol (abfd, info, h, name, isym, - &sec, &value, &dynsym, - override)) - goto error_free_vers; - - if (definition && !dynamic) - { - char *p = strchr (name, ELF_VER_CHR); - if (p != NULL && p[1] != ELF_VER_CHR) - { - /* Queue non-default versions so that .symver x, x@FOO - aliases can be checked. */ - if (! nondeflt_vers) - { - amt = (isymend - isym + 1) - * sizeof (struct elf_link_hash_entry *); - nondeflt_vers = bfd_malloc (amt); - } - nondeflt_vers [nondeflt_vers_cnt++] = h; - } - } - - if (dynsym && h->dynindx == -1) - { - if (! _bfd_elf_link_record_dynamic_symbol (info, h)) - goto error_free_vers; - if (h->weakdef != NULL - && ! new_weakdef - && h->weakdef->dynindx == -1) - { - if (! _bfd_elf_link_record_dynamic_symbol (info, h->weakdef)) - goto error_free_vers; - } - } - else if (dynsym && h->dynindx != -1) - /* If the symbol already has a dynamic index, but - visibility says it should not be visible, turn it into - a local symbol. */ - switch (ELF_ST_VISIBILITY (h->other)) - { - case STV_INTERNAL: - case STV_HIDDEN: - (*bed->elf_backend_hide_symbol) (info, h, TRUE); - break; - } - - if (!add_needed && definition - && (h->elf_link_hash_flags - & ELF_LINK_HASH_REF_REGULAR) != 0) - { - int ret; - - /* A symbol from a library loaded via DT_NEEDED of some - other library is referenced by a regular object. - Add a DT_NEEDED entry for it. */ - add_needed = TRUE; - ret = add_dt_needed_tag (info, elf_dt_name (abfd), add_needed); - if (ret < 0) - goto error_free_vers; - - BFD_ASSERT (ret == 0); - } - } - } - - /* Now that all the symbols from this input file are created, handle - .symver foo, foo@BAR such that any relocs against foo become foo@BAR. */ - if (nondeflt_vers != NULL) - { - bfd_size_type cnt, symidx; - - for (cnt = 0; cnt < nondeflt_vers_cnt; ++cnt) - { - struct elf_link_hash_entry *h = nondeflt_vers[cnt], *hi; - char *shortname, *p; - - p = strchr (h->root.root.string, ELF_VER_CHR); - if (p == NULL - || (h->root.type != bfd_link_hash_defined - && h->root.type != bfd_link_hash_defweak)) - continue; - - amt = p - h->root.root.string; - shortname = bfd_malloc (amt + 1); - memcpy (shortname, h->root.root.string, amt); - shortname[amt] = '\0'; - - hi = (struct elf_link_hash_entry *) - bfd_link_hash_lookup (&hash_table->root, shortname, - FALSE, FALSE, FALSE); - if (hi != NULL - && hi->root.type == h->root.type - && hi->root.u.def.value == h->root.u.def.value - && hi->root.u.def.section == h->root.u.def.section) - { - (*bed->elf_backend_hide_symbol) (info, hi, TRUE); - hi->root.type = bfd_link_hash_indirect; - hi->root.u.i.link = (struct bfd_link_hash_entry *) h; - (*bed->elf_backend_copy_indirect_symbol) (bed, h, hi); - sym_hash = elf_sym_hashes (abfd); - if (sym_hash) - for (symidx = 0; symidx < extsymcount; ++symidx) - if (sym_hash[symidx] == hi) - { - sym_hash[symidx] = h; - break; - } - } - free (shortname); - } - free (nondeflt_vers); - nondeflt_vers = NULL; - } - - if (extversym != NULL) - { - free (extversym); - extversym = NULL; - } - - if (isymbuf != NULL) - free (isymbuf); - isymbuf = NULL; - - /* Now set the weakdefs field correctly for all the weak defined - symbols we found. The only way to do this is to search all the - symbols. Since we only need the information for non functions in - dynamic objects, that's the only time we actually put anything on - the list WEAKS. We need this information so that if a regular - object refers to a symbol defined weakly in a dynamic object, the - real symbol in the dynamic object is also put in the dynamic - symbols; we also must arrange for both symbols to point to the - same memory location. We could handle the general case of symbol - aliasing, but a general symbol alias can only be generated in - assembler code, handling it correctly would be very time - consuming, and other ELF linkers don't handle general aliasing - either. */ - if (weaks != NULL) - { - struct elf_link_hash_entry **hpp; - struct elf_link_hash_entry **hppend; - struct elf_link_hash_entry **sorted_sym_hash; - struct elf_link_hash_entry *h; - size_t sym_count; - - /* Since we have to search the whole symbol list for each weak - defined symbol, search time for N weak defined symbols will be - O(N^2). Binary search will cut it down to O(NlogN). */ - amt = extsymcount * sizeof (struct elf_link_hash_entry *); - sorted_sym_hash = bfd_malloc (amt); - if (sorted_sym_hash == NULL) - goto error_return; - sym_hash = sorted_sym_hash; - hpp = elf_sym_hashes (abfd); - hppend = hpp + extsymcount; - sym_count = 0; - for (; hpp < hppend; hpp++) - { - h = *hpp; - if (h != NULL - && h->root.type == bfd_link_hash_defined - && h->type != STT_FUNC) - { - *sym_hash = h; - sym_hash++; - sym_count++; - } - } - - qsort (sorted_sym_hash, sym_count, - sizeof (struct elf_link_hash_entry *), - sort_symbol); - - while (weaks != NULL) - { - struct elf_link_hash_entry *hlook; - asection *slook; - bfd_vma vlook; - long ilook; - size_t i, j, idx; - - hlook = weaks; - weaks = hlook->weakdef; - hlook->weakdef = NULL; - - BFD_ASSERT (hlook->root.type == bfd_link_hash_defined - || hlook->root.type == bfd_link_hash_defweak - || hlook->root.type == bfd_link_hash_common - || hlook->root.type == bfd_link_hash_indirect); - slook = hlook->root.u.def.section; - vlook = hlook->root.u.def.value; - - ilook = -1; - i = 0; - j = sym_count; - while (i < j) - { - bfd_signed_vma vdiff; - idx = (i + j) / 2; - h = sorted_sym_hash [idx]; - vdiff = vlook - h->root.u.def.value; - if (vdiff < 0) - j = idx; - else if (vdiff > 0) - i = idx + 1; - else - { - long sdiff = slook - h->root.u.def.section; - if (sdiff < 0) - j = idx; - else if (sdiff > 0) - i = idx + 1; - else - { - ilook = idx; - break; - } - } - } - - /* We didn't find a value/section match. */ - if (ilook == -1) - continue; - - for (i = ilook; i < sym_count; i++) - { - h = sorted_sym_hash [i]; - - /* Stop if value or section doesn't match. */ - if (h->root.u.def.value != vlook - || h->root.u.def.section != slook) - break; - else if (h != hlook) - { - hlook->weakdef = h; - - /* If the weak definition is in the list of dynamic - symbols, make sure the real definition is put - there as well. */ - if (hlook->dynindx != -1 && h->dynindx == -1) - { - if (! _bfd_elf_link_record_dynamic_symbol (info, - h)) - goto error_return; - } - - /* If the real definition is in the list of dynamic - symbols, make sure the weak definition is put - there as well. If we don't do this, then the - dynamic loader might not merge the entries for the - real definition and the weak definition. */ - if (h->dynindx != -1 && hlook->dynindx == -1) - { - if (! _bfd_elf_link_record_dynamic_symbol (info, - hlook)) - goto error_return; - } - break; - } - } - } - - free (sorted_sym_hash); - } - - /* If this object is the same format as the output object, and it is - not a shared library, then let the backend look through the - relocs. - - This is required to build global offset table entries and to - arrange for dynamic relocs. It is not required for the - particular common case of linking non PIC code, even when linking - against shared libraries, but unfortunately there is no way of - knowing whether an object file has been compiled PIC or not. - Looking through the relocs is not particularly time consuming. - The problem is that we must either (1) keep the relocs in memory, - which causes the linker to require additional runtime memory or - (2) read the relocs twice from the input file, which wastes time. - This would be a good case for using mmap. - - I have no idea how to handle linking PIC code into a file of a - different format. It probably can't be done. */ - check_relocs = get_elf_backend_data (abfd)->check_relocs; - if (! dynamic - && is_elf_hash_table (hash_table) - && hash_table->root.creator == abfd->xvec - && check_relocs != NULL) - { - asection *o; - - for (o = abfd->sections; o != NULL; o = o->next) - { - Elf_Internal_Rela *internal_relocs; - bfd_boolean ok; - - if ((o->flags & SEC_RELOC) == 0 - || o->reloc_count == 0 - || ((info->strip == strip_all || info->strip == strip_debugger) - && (o->flags & SEC_DEBUGGING) != 0) - || bfd_is_abs_section (o->output_section)) - continue; - - internal_relocs = _bfd_elf_link_read_relocs (abfd, o, NULL, NULL, - info->keep_memory); - if (internal_relocs == NULL) - goto error_return; - - ok = (*check_relocs) (abfd, info, o, internal_relocs); - - if (elf_section_data (o)->relocs != internal_relocs) - free (internal_relocs); - - if (! ok) - goto error_return; - } - } - - /* If this is a non-traditional link, try to optimize the handling - of the .stab/.stabstr sections. */ - if (! dynamic - && ! info->traditional_format - && is_elf_hash_table (hash_table) - && (info->strip != strip_all && info->strip != strip_debugger)) - { - asection *stabstr; - - stabstr = bfd_get_section_by_name (abfd, ".stabstr"); - if (stabstr != NULL) - { - bfd_size_type string_offset = 0; - asection *stab; - - for (stab = abfd->sections; stab; stab = stab->next) - if (strncmp (".stab", stab->name, 5) == 0 - && (!stab->name[5] || - (stab->name[5] == '.' && ISDIGIT (stab->name[6]))) - && (stab->flags & SEC_MERGE) == 0 - && !bfd_is_abs_section (stab->output_section)) - { - struct bfd_elf_section_data *secdata; - - secdata = elf_section_data (stab); - if (! _bfd_link_section_stabs (abfd, - & hash_table->stab_info, - stab, stabstr, - &secdata->sec_info, - &string_offset)) - goto error_return; - if (secdata->sec_info) - stab->sec_info_type = ELF_INFO_TYPE_STABS; - } - } - } - - if (! info->relocatable - && ! dynamic - && is_elf_hash_table (hash_table)) - { - asection *s; - - for (s = abfd->sections; s != NULL; s = s->next) - if ((s->flags & SEC_MERGE) != 0 - && !bfd_is_abs_section (s->output_section)) - { - struct bfd_elf_section_data *secdata; - - secdata = elf_section_data (s); - if (! _bfd_merge_section (abfd, - & hash_table->merge_info, - s, &secdata->sec_info)) - goto error_return; - else if (secdata->sec_info) - s->sec_info_type = ELF_INFO_TYPE_MERGE; - } - } - - if (is_elf_hash_table (hash_table)) - { - /* Add this bfd to the loaded list. */ - struct elf_link_loaded_list *n; - - n = bfd_alloc (abfd, sizeof (struct elf_link_loaded_list)); - if (n == NULL) - goto error_return; - n->abfd = abfd; - n->next = hash_table->loaded; - hash_table->loaded = n; - } - - return TRUE; - - error_free_vers: - if (nondeflt_vers != NULL) - free (nondeflt_vers); - if (extversym != NULL) - free (extversym); - error_free_sym: - if (isymbuf != NULL) - free (isymbuf); - error_return: - return FALSE; -} - -/* Add an entry to the .dynamic table. */ - -bfd_boolean -elf_add_dynamic_entry (struct bfd_link_info *info, bfd_vma tag, bfd_vma val) -{ - Elf_Internal_Dyn dyn; - bfd *dynobj; - asection *s; - bfd_size_type newsize; - bfd_byte *newcontents; - - if (! is_elf_hash_table (info->hash)) - return FALSE; - - dynobj = elf_hash_table (info)->dynobj; - - s = bfd_get_section_by_name (dynobj, ".dynamic"); - BFD_ASSERT (s != NULL); - - newsize = s->_raw_size + sizeof (Elf_External_Dyn); - newcontents = bfd_realloc (s->contents, newsize); - if (newcontents == NULL) - return FALSE; - - dyn.d_tag = tag; - dyn.d_un.d_val = val; - elf_swap_dyn_out (dynobj, &dyn, - (Elf_External_Dyn *) (newcontents + s->_raw_size)); - - s->_raw_size = newsize; - s->contents = newcontents; - - return TRUE; -} - -/* Array used to determine the number of hash table buckets to use - based on the number of symbols there are. If there are fewer than - 3 symbols we use 1 bucket, fewer than 17 symbols we use 3 buckets, - fewer than 37 we use 17 buckets, and so forth. We never use more - than 32771 buckets. */ - -static const size_t elf_buckets[] = -{ - 1, 3, 17, 37, 67, 97, 131, 197, 263, 521, 1031, 2053, 4099, 8209, - 16411, 32771, 0 -}; - -/* Compute bucket count for hashing table. We do not use a static set - of possible tables sizes anymore. Instead we determine for all - possible reasonable sizes of the table the outcome (i.e., the - number of collisions etc) and choose the best solution. The - weighting functions are not too simple to allow the table to grow - without bounds. Instead one of the weighting factors is the size. - Therefore the result is always a good payoff between few collisions - (= short chain lengths) and table size. */ -static size_t -compute_bucket_count (struct bfd_link_info *info) -{ - size_t dynsymcount = elf_hash_table (info)->dynsymcount; - size_t best_size = 0; - unsigned long int *hashcodes; - unsigned long int *hashcodesp; - unsigned long int i; - bfd_size_type amt; - - /* Compute the hash values for all exported symbols. At the same - time store the values in an array so that we could use them for - optimizations. */ - amt = dynsymcount; - amt *= sizeof (unsigned long int); - hashcodes = bfd_malloc (amt); - if (hashcodes == NULL) - return 0; - hashcodesp = hashcodes; - - /* Put all hash values in HASHCODES. */ - elf_link_hash_traverse (elf_hash_table (info), - elf_collect_hash_codes, &hashcodesp); - - /* We have a problem here. The following code to optimize the table - size requires an integer type with more the 32 bits. If - BFD_HOST_U_64_BIT is set we know about such a type. */ -#ifdef BFD_HOST_U_64_BIT - if (info->optimize) - { - unsigned long int nsyms = hashcodesp - hashcodes; - size_t minsize; - size_t maxsize; - BFD_HOST_U_64_BIT best_chlen = ~((BFD_HOST_U_64_BIT) 0); - unsigned long int *counts ; - - /* Possible optimization parameters: if we have NSYMS symbols we say - that the hashing table must at least have NSYMS/4 and at most - 2*NSYMS buckets. */ - minsize = nsyms / 4; - if (minsize == 0) - minsize = 1; - best_size = maxsize = nsyms * 2; - - /* Create array where we count the collisions in. We must use bfd_malloc - since the size could be large. */ - amt = maxsize; - amt *= sizeof (unsigned long int); - counts = bfd_malloc (amt); - if (counts == NULL) - { - free (hashcodes); - return 0; - } - - /* Compute the "optimal" size for the hash table. The criteria is a - minimal chain length. The minor criteria is (of course) the size - of the table. */ - for (i = minsize; i < maxsize; ++i) - { - /* Walk through the array of hashcodes and count the collisions. */ - BFD_HOST_U_64_BIT max; - unsigned long int j; - unsigned long int fact; - - memset (counts, '\0', i * sizeof (unsigned long int)); - - /* Determine how often each hash bucket is used. */ - for (j = 0; j < nsyms; ++j) - ++counts[hashcodes[j] % i]; - - /* For the weight function we need some information about the - pagesize on the target. This is information need not be 100% - accurate. Since this information is not available (so far) we - define it here to a reasonable default value. If it is crucial - to have a better value some day simply define this value. */ -# ifndef BFD_TARGET_PAGESIZE -# define BFD_TARGET_PAGESIZE (4096) -# endif - - /* We in any case need 2 + NSYMS entries for the size values and - the chains. */ - max = (2 + nsyms) * (ARCH_SIZE / 8); - -# if 1 - /* Variant 1: optimize for short chains. We add the squares - of all the chain lengths (which favors many small chain - over a few long chains). */ - for (j = 0; j < i; ++j) - max += counts[j] * counts[j]; - - /* This adds penalties for the overall size of the table. */ - fact = i / (BFD_TARGET_PAGESIZE / (ARCH_SIZE / 8)) + 1; - max *= fact * fact; -# else - /* Variant 2: Optimize a lot more for small table. Here we - also add squares of the size but we also add penalties for - empty slots (the +1 term). */ - for (j = 0; j < i; ++j) - max += (1 + counts[j]) * (1 + counts[j]); - - /* The overall size of the table is considered, but not as - strong as in variant 1, where it is squared. */ - fact = i / (BFD_TARGET_PAGESIZE / (ARCH_SIZE / 8)) + 1; - max *= fact; -# endif - - /* Compare with current best results. */ - if (max < best_chlen) - { - best_chlen = max; - best_size = i; - } - } - - free (counts); - } - else -#endif /* defined (BFD_HOST_U_64_BIT) */ - { - /* This is the fallback solution if no 64bit type is available or if we - are not supposed to spend much time on optimizations. We select the - bucket count using a fixed set of numbers. */ - for (i = 0; elf_buckets[i] != 0; i++) - { - best_size = elf_buckets[i]; - if (dynsymcount < elf_buckets[i + 1]) - break; - } - } - - /* Free the arrays we needed. */ - free (hashcodes); - - return best_size; -} - -/* Set up the sizes and contents of the ELF dynamic sections. This is - called by the ELF linker emulation before_allocation routine. We - must set the sizes of the sections before the linker sets the - addresses of the various sections. */ - -bfd_boolean -NAME(bfd_elf,size_dynamic_sections) (bfd *output_bfd, - const char *soname, - const char *rpath, - const char *filter_shlib, - const char * const *auxiliary_filters, - struct bfd_link_info *info, - asection **sinterpptr, - struct bfd_elf_version_tree *verdefs) -{ - bfd_size_type soname_indx; - bfd *dynobj; - const struct elf_backend_data *bed; - struct elf_assign_sym_version_info asvinfo; - - *sinterpptr = NULL; - - soname_indx = (bfd_size_type) -1; - - if (!is_elf_hash_table (info->hash)) - return TRUE; - - if (info->execstack) - elf_tdata (output_bfd)->stack_flags = PF_R | PF_W | PF_X; - else if (info->noexecstack) - elf_tdata (output_bfd)->stack_flags = PF_R | PF_W; - else - { - bfd *inputobj; - asection *notesec = NULL; - int exec = 0; - - for (inputobj = info->input_bfds; - inputobj; - inputobj = inputobj->link_next) - { - asection *s; - - if (inputobj->flags & DYNAMIC) - continue; - s = bfd_get_section_by_name (inputobj, ".note.GNU-stack"); - if (s) - { - if (s->flags & SEC_CODE) - exec = PF_X; - notesec = s; - } - else - exec = PF_X; - } - if (notesec) - { - elf_tdata (output_bfd)->stack_flags = PF_R | PF_W | exec; - if (exec && info->relocatable - && notesec->output_section != bfd_abs_section_ptr) - notesec->output_section->flags |= SEC_CODE; - } - } - - /* Any syms created from now on start with -1 in - got.refcount/offset and plt.refcount/offset. */ - elf_hash_table (info)->init_refcount = elf_hash_table (info)->init_offset; - - /* The backend may have to create some sections regardless of whether - we're dynamic or not. */ - bed = get_elf_backend_data (output_bfd); - if (bed->elf_backend_always_size_sections - && ! (*bed->elf_backend_always_size_sections) (output_bfd, info)) - return FALSE; - - dynobj = elf_hash_table (info)->dynobj; - - /* If there were no dynamic objects in the link, there is nothing to - do here. */ - if (dynobj == NULL) - return TRUE; - - if (! _bfd_elf_maybe_strip_eh_frame_hdr (info)) - return FALSE; - - if (elf_hash_table (info)->dynamic_sections_created) - { - struct elf_info_failed eif; - struct elf_link_hash_entry *h; - asection *dynstr; - struct bfd_elf_version_tree *t; - struct bfd_elf_version_expr *d; - bfd_boolean all_defined; - - *sinterpptr = bfd_get_section_by_name (dynobj, ".interp"); - BFD_ASSERT (*sinterpptr != NULL || !info->executable); - - if (soname != NULL) - { - soname_indx = _bfd_elf_strtab_add (elf_hash_table (info)->dynstr, - soname, TRUE); - if (soname_indx == (bfd_size_type) -1 - || ! elf_add_dynamic_entry (info, DT_SONAME, soname_indx)) - return FALSE; - } - - if (info->symbolic) - { - if (! elf_add_dynamic_entry (info, DT_SYMBOLIC, 0)) - return FALSE; - info->flags |= DF_SYMBOLIC; - } - - if (rpath != NULL) - { - bfd_size_type indx; - - indx = _bfd_elf_strtab_add (elf_hash_table (info)->dynstr, rpath, - TRUE); - if (info->new_dtags) - _bfd_elf_strtab_addref (elf_hash_table (info)->dynstr, indx); - if (indx == (bfd_size_type) -1 - || ! elf_add_dynamic_entry (info, DT_RPATH, indx) - || (info->new_dtags - && ! elf_add_dynamic_entry (info, DT_RUNPATH, indx))) - return FALSE; - } - - if (filter_shlib != NULL) - { - bfd_size_type indx; - - indx = _bfd_elf_strtab_add (elf_hash_table (info)->dynstr, - filter_shlib, TRUE); - if (indx == (bfd_size_type) -1 - || ! elf_add_dynamic_entry (info, DT_FILTER, indx)) - return FALSE; - } - - if (auxiliary_filters != NULL) - { - const char * const *p; - - for (p = auxiliary_filters; *p != NULL; p++) - { - bfd_size_type indx; - - indx = _bfd_elf_strtab_add (elf_hash_table (info)->dynstr, - *p, TRUE); - if (indx == (bfd_size_type) -1 - || ! elf_add_dynamic_entry (info, DT_AUXILIARY, indx)) - return FALSE; - } - } - - eif.info = info; - eif.verdefs = verdefs; - eif.failed = FALSE; - - /* If we are supposed to export all symbols into the dynamic symbol - table (this is not the normal case), then do so. */ - if (info->export_dynamic) - { - elf_link_hash_traverse (elf_hash_table (info), - _bfd_elf_export_symbol, - &eif); - if (eif.failed) - return FALSE; - } - - /* Make all global versions with definition. */ - for (t = verdefs; t != NULL; t = t->next) - for (d = t->globals.list; d != NULL; d = d->next) - if (!d->symver && d->symbol) - { - const char *verstr, *name; - size_t namelen, verlen, newlen; - char *newname, *p; - struct elf_link_hash_entry *newh; - - name = d->symbol; - namelen = strlen (name); - verstr = t->name; - verlen = strlen (verstr); - newlen = namelen + verlen + 3; - - newname = bfd_malloc (newlen); - if (newname == NULL) - return FALSE; - memcpy (newname, name, namelen); - - /* Check the hidden versioned definition. */ - p = newname + namelen; - *p++ = ELF_VER_CHR; - memcpy (p, verstr, verlen + 1); - newh = elf_link_hash_lookup (elf_hash_table (info), - newname, FALSE, FALSE, - FALSE); - if (newh == NULL - || (newh->root.type != bfd_link_hash_defined - && newh->root.type != bfd_link_hash_defweak)) - { - /* Check the default versioned definition. */ - *p++ = ELF_VER_CHR; - memcpy (p, verstr, verlen + 1); - newh = elf_link_hash_lookup (elf_hash_table (info), - newname, FALSE, FALSE, - FALSE); - } - free (newname); - - /* Mark this version if there is a definition and it is - not defined in a shared object. */ - if (newh != NULL - && ((newh->elf_link_hash_flags - & ELF_LINK_HASH_DEF_DYNAMIC) == 0) - && (newh->root.type == bfd_link_hash_defined - || newh->root.type == bfd_link_hash_defweak)) - d->symver = 1; - } - - /* Attach all the symbols to their version information. */ - asvinfo.output_bfd = output_bfd; - asvinfo.info = info; - asvinfo.verdefs = verdefs; - asvinfo.failed = FALSE; - - elf_link_hash_traverse (elf_hash_table (info), - _bfd_elf_link_assign_sym_version, - &asvinfo); - if (asvinfo.failed) - return FALSE; - - if (!info->allow_undefined_version) - { - /* Check if all global versions have a definition. */ - all_defined = TRUE; - for (t = verdefs; t != NULL; t = t->next) - for (d = t->globals.list; d != NULL; d = d->next) - if (!d->symver && !d->script) - { - (*_bfd_error_handler) - (_("%s: undefined version: %s"), - d->pattern, t->name); - all_defined = FALSE; - } - - if (!all_defined) - { - bfd_set_error (bfd_error_bad_value); - return FALSE; - } - } - - /* Find all symbols which were defined in a dynamic object and make - the backend pick a reasonable value for them. */ - elf_link_hash_traverse (elf_hash_table (info), - _bfd_elf_adjust_dynamic_symbol, - &eif); - if (eif.failed) - return FALSE; - - /* Add some entries to the .dynamic section. We fill in some of the - values later, in elf_bfd_final_link, but we must add the entries - now so that we know the final size of the .dynamic section. */ - - /* If there are initialization and/or finalization functions to - call then add the corresponding DT_INIT/DT_FINI entries. */ - h = (info->init_function - ? elf_link_hash_lookup (elf_hash_table (info), - info->init_function, FALSE, - FALSE, FALSE) - : NULL); - if (h != NULL - && (h->elf_link_hash_flags & (ELF_LINK_HASH_REF_REGULAR - | ELF_LINK_HASH_DEF_REGULAR)) != 0) - { - if (! elf_add_dynamic_entry (info, DT_INIT, 0)) - return FALSE; - } - h = (info->fini_function - ? elf_link_hash_lookup (elf_hash_table (info), - info->fini_function, FALSE, - FALSE, FALSE) - : NULL); - if (h != NULL - && (h->elf_link_hash_flags & (ELF_LINK_HASH_REF_REGULAR - | ELF_LINK_HASH_DEF_REGULAR)) != 0) - { - if (! elf_add_dynamic_entry (info, DT_FINI, 0)) - return FALSE; - } - - if (bfd_get_section_by_name (output_bfd, ".preinit_array") != NULL) - { - /* DT_PREINIT_ARRAY is not allowed in shared library. */ - if (! info->executable) - { - bfd *sub; - asection *o; - - for (sub = info->input_bfds; sub != NULL; - sub = sub->link_next) - for (o = sub->sections; o != NULL; o = o->next) - if (elf_section_data (o)->this_hdr.sh_type - == SHT_PREINIT_ARRAY) - { - (*_bfd_error_handler) - (_("%s: .preinit_array section is not allowed in DSO"), - bfd_archive_filename (sub)); - break; - } - - bfd_set_error (bfd_error_nonrepresentable_section); - return FALSE; - } - - if (!elf_add_dynamic_entry (info, DT_PREINIT_ARRAY, 0) - || !elf_add_dynamic_entry (info, DT_PREINIT_ARRAYSZ, 0)) - return FALSE; - } - if (bfd_get_section_by_name (output_bfd, ".init_array") != NULL) - { - if (!elf_add_dynamic_entry (info, DT_INIT_ARRAY, 0) - || !elf_add_dynamic_entry (info, DT_INIT_ARRAYSZ, 0)) - return FALSE; - } - if (bfd_get_section_by_name (output_bfd, ".fini_array") != NULL) - { - if (!elf_add_dynamic_entry (info, DT_FINI_ARRAY, 0) - || !elf_add_dynamic_entry (info, DT_FINI_ARRAYSZ, 0)) - return FALSE; - } - - dynstr = bfd_get_section_by_name (dynobj, ".dynstr"); - /* If .dynstr is excluded from the link, we don't want any of - these tags. Strictly, we should be checking each section - individually; This quick check covers for the case where - someone does a /DISCARD/ : { *(*) }. */ - if (dynstr != NULL && dynstr->output_section != bfd_abs_section_ptr) - { - bfd_size_type strsize; - - strsize = _bfd_elf_strtab_size (elf_hash_table (info)->dynstr); - if (! elf_add_dynamic_entry (info, DT_HASH, 0) - || ! elf_add_dynamic_entry (info, DT_STRTAB, 0) - || ! elf_add_dynamic_entry (info, DT_SYMTAB, 0) - || ! elf_add_dynamic_entry (info, DT_STRSZ, strsize) - || ! elf_add_dynamic_entry (info, DT_SYMENT, - sizeof (Elf_External_Sym))) - return FALSE; - } - } - - /* The backend must work out the sizes of all the other dynamic - sections. */ - if (bed->elf_backend_size_dynamic_sections - && ! (*bed->elf_backend_size_dynamic_sections) (output_bfd, info)) - return FALSE; - - if (elf_hash_table (info)->dynamic_sections_created) - { - bfd_size_type dynsymcount; - asection *s; - size_t bucketcount = 0; - size_t hash_entry_size; - unsigned int dtagcount; - - /* Set up the version definition section. */ - s = bfd_get_section_by_name (dynobj, ".gnu.version_d"); - BFD_ASSERT (s != NULL); - - /* We may have created additional version definitions if we are - just linking a regular application. */ - verdefs = asvinfo.verdefs; - - /* Skip anonymous version tag. */ - if (verdefs != NULL && verdefs->vernum == 0) - verdefs = verdefs->next; - - if (verdefs == NULL) - _bfd_strip_section_from_output (info, s); - else - { - unsigned int cdefs; - bfd_size_type size; - struct bfd_elf_version_tree *t; - bfd_byte *p; - Elf_Internal_Verdef def; - Elf_Internal_Verdaux defaux; - - cdefs = 0; - size = 0; - - /* Make space for the base version. */ - size += sizeof (Elf_External_Verdef); - size += sizeof (Elf_External_Verdaux); - ++cdefs; - - for (t = verdefs; t != NULL; t = t->next) - { - struct bfd_elf_version_deps *n; - - size += sizeof (Elf_External_Verdef); - size += sizeof (Elf_External_Verdaux); - ++cdefs; - - for (n = t->deps; n != NULL; n = n->next) - size += sizeof (Elf_External_Verdaux); - } - - s->_raw_size = size; - s->contents = bfd_alloc (output_bfd, s->_raw_size); - if (s->contents == NULL && s->_raw_size != 0) - return FALSE; - - /* Fill in the version definition section. */ - - p = s->contents; - - def.vd_version = VER_DEF_CURRENT; - def.vd_flags = VER_FLG_BASE; - def.vd_ndx = 1; - def.vd_cnt = 1; - def.vd_aux = sizeof (Elf_External_Verdef); - def.vd_next = (sizeof (Elf_External_Verdef) - + sizeof (Elf_External_Verdaux)); - - if (soname_indx != (bfd_size_type) -1) - { - _bfd_elf_strtab_addref (elf_hash_table (info)->dynstr, - soname_indx); - def.vd_hash = bfd_elf_hash (soname); - defaux.vda_name = soname_indx; - } - else - { - const char *name; - bfd_size_type indx; - - name = basename (output_bfd->filename); - def.vd_hash = bfd_elf_hash (name); - indx = _bfd_elf_strtab_add (elf_hash_table (info)->dynstr, - name, FALSE); - if (indx == (bfd_size_type) -1) - return FALSE; - defaux.vda_name = indx; - } - defaux.vda_next = 0; - - _bfd_elf_swap_verdef_out (output_bfd, &def, - (Elf_External_Verdef *) p); - p += sizeof (Elf_External_Verdef); - _bfd_elf_swap_verdaux_out (output_bfd, &defaux, - (Elf_External_Verdaux *) p); - p += sizeof (Elf_External_Verdaux); - - for (t = verdefs; t != NULL; t = t->next) - { - unsigned int cdeps; - struct bfd_elf_version_deps *n; - struct elf_link_hash_entry *h; - struct bfd_link_hash_entry *bh; - - cdeps = 0; - for (n = t->deps; n != NULL; n = n->next) - ++cdeps; - - /* Add a symbol representing this version. */ - bh = NULL; - if (! (_bfd_generic_link_add_one_symbol - (info, dynobj, t->name, BSF_GLOBAL, bfd_abs_section_ptr, - 0, NULL, FALSE, - get_elf_backend_data (dynobj)->collect, &bh))) - return FALSE; - h = (struct elf_link_hash_entry *) bh; - h->elf_link_hash_flags &= ~ ELF_LINK_NON_ELF; - h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR; - h->type = STT_OBJECT; - h->verinfo.vertree = t; - - if (! _bfd_elf_link_record_dynamic_symbol (info, h)) - return FALSE; - - def.vd_version = VER_DEF_CURRENT; - def.vd_flags = 0; - if (t->globals.list == NULL && t->locals.list == NULL && ! t->used) - def.vd_flags |= VER_FLG_WEAK; - def.vd_ndx = t->vernum + 1; - def.vd_cnt = cdeps + 1; - def.vd_hash = bfd_elf_hash (t->name); - def.vd_aux = sizeof (Elf_External_Verdef); - if (t->next != NULL) - def.vd_next = (sizeof (Elf_External_Verdef) - + (cdeps + 1) * sizeof (Elf_External_Verdaux)); - else - def.vd_next = 0; - - _bfd_elf_swap_verdef_out (output_bfd, &def, - (Elf_External_Verdef *) p); - p += sizeof (Elf_External_Verdef); - - defaux.vda_name = h->dynstr_index; - _bfd_elf_strtab_addref (elf_hash_table (info)->dynstr, - h->dynstr_index); - if (t->deps == NULL) - defaux.vda_next = 0; - else - defaux.vda_next = sizeof (Elf_External_Verdaux); - t->name_indx = defaux.vda_name; - - _bfd_elf_swap_verdaux_out (output_bfd, &defaux, - (Elf_External_Verdaux *) p); - p += sizeof (Elf_External_Verdaux); - - for (n = t->deps; n != NULL; n = n->next) - { - if (n->version_needed == NULL) - { - /* This can happen if there was an error in the - version script. */ - defaux.vda_name = 0; - } - else - { - defaux.vda_name = n->version_needed->name_indx; - _bfd_elf_strtab_addref (elf_hash_table (info)->dynstr, - defaux.vda_name); - } - if (n->next == NULL) - defaux.vda_next = 0; - else - defaux.vda_next = sizeof (Elf_External_Verdaux); - - _bfd_elf_swap_verdaux_out (output_bfd, &defaux, - (Elf_External_Verdaux *) p); - p += sizeof (Elf_External_Verdaux); - } - } - - if (! elf_add_dynamic_entry (info, DT_VERDEF, 0) - || ! elf_add_dynamic_entry (info, DT_VERDEFNUM, cdefs)) - return FALSE; - - elf_tdata (output_bfd)->cverdefs = cdefs; - } - - if ((info->new_dtags && info->flags) || (info->flags & DF_STATIC_TLS)) - { - if (! elf_add_dynamic_entry (info, DT_FLAGS, info->flags)) - return FALSE; - } - else if (info->flags & DF_BIND_NOW) - { - if (! elf_add_dynamic_entry (info, DT_BIND_NOW, 0)) - return FALSE; - } - - if (info->flags_1) - { - if (info->executable) - info->flags_1 &= ~ (DF_1_INITFIRST - | DF_1_NODELETE - | DF_1_NOOPEN); - if (! elf_add_dynamic_entry (info, DT_FLAGS_1, info->flags_1)) - return FALSE; - } - - /* Work out the size of the version reference section. */ - - s = bfd_get_section_by_name (dynobj, ".gnu.version_r"); - BFD_ASSERT (s != NULL); - { - struct elf_find_verdep_info sinfo; - - sinfo.output_bfd = output_bfd; - sinfo.info = info; - sinfo.vers = elf_tdata (output_bfd)->cverdefs; - if (sinfo.vers == 0) - sinfo.vers = 1; - sinfo.failed = FALSE; - - elf_link_hash_traverse (elf_hash_table (info), - _bfd_elf_link_find_version_dependencies, - &sinfo); - - if (elf_tdata (output_bfd)->verref == NULL) - _bfd_strip_section_from_output (info, s); - else - { - Elf_Internal_Verneed *t; - unsigned int size; - unsigned int crefs; - bfd_byte *p; - - /* Build the version definition section. */ - size = 0; - crefs = 0; - for (t = elf_tdata (output_bfd)->verref; - t != NULL; - t = t->vn_nextref) - { - Elf_Internal_Vernaux *a; - - size += sizeof (Elf_External_Verneed); - ++crefs; - for (a = t->vn_auxptr; a != NULL; a = a->vna_nextptr) - size += sizeof (Elf_External_Vernaux); - } - - s->_raw_size = size; - s->contents = bfd_alloc (output_bfd, s->_raw_size); - if (s->contents == NULL) - return FALSE; - - p = s->contents; - for (t = elf_tdata (output_bfd)->verref; - t != NULL; - t = t->vn_nextref) - { - unsigned int caux; - Elf_Internal_Vernaux *a; - bfd_size_type indx; - - caux = 0; - for (a = t->vn_auxptr; a != NULL; a = a->vna_nextptr) - ++caux; - - t->vn_version = VER_NEED_CURRENT; - t->vn_cnt = caux; - indx = _bfd_elf_strtab_add (elf_hash_table (info)->dynstr, - elf_dt_name (t->vn_bfd) != NULL - ? elf_dt_name (t->vn_bfd) - : basename (t->vn_bfd->filename), - FALSE); - if (indx == (bfd_size_type) -1) - return FALSE; - t->vn_file = indx; - t->vn_aux = sizeof (Elf_External_Verneed); - if (t->vn_nextref == NULL) - t->vn_next = 0; - else - t->vn_next = (sizeof (Elf_External_Verneed) - + caux * sizeof (Elf_External_Vernaux)); - - _bfd_elf_swap_verneed_out (output_bfd, t, - (Elf_External_Verneed *) p); - p += sizeof (Elf_External_Verneed); - - for (a = t->vn_auxptr; a != NULL; a = a->vna_nextptr) - { - a->vna_hash = bfd_elf_hash (a->vna_nodename); - indx = _bfd_elf_strtab_add (elf_hash_table (info)->dynstr, - a->vna_nodename, FALSE); - if (indx == (bfd_size_type) -1) - return FALSE; - a->vna_name = indx; - if (a->vna_nextptr == NULL) - a->vna_next = 0; - else - a->vna_next = sizeof (Elf_External_Vernaux); - - _bfd_elf_swap_vernaux_out (output_bfd, a, - (Elf_External_Vernaux *) p); - p += sizeof (Elf_External_Vernaux); - } - } - - if (! elf_add_dynamic_entry (info, DT_VERNEED, 0) - || ! elf_add_dynamic_entry (info, DT_VERNEEDNUM, crefs)) - return FALSE; - - elf_tdata (output_bfd)->cverrefs = crefs; - } - } - - /* Assign dynsym indicies. In a shared library we generate a - section symbol for each output section, which come first. - Next come all of the back-end allocated local dynamic syms, - followed by the rest of the global symbols. */ - - dynsymcount = _bfd_elf_link_renumber_dynsyms (output_bfd, info); - - /* Work out the size of the symbol version section. */ - s = bfd_get_section_by_name (dynobj, ".gnu.version"); - BFD_ASSERT (s != NULL); - if (dynsymcount == 0 - || (verdefs == NULL && elf_tdata (output_bfd)->verref == NULL)) - { - _bfd_strip_section_from_output (info, s); - /* The DYNSYMCOUNT might have changed if we were going to - output a dynamic symbol table entry for S. */ - dynsymcount = _bfd_elf_link_renumber_dynsyms (output_bfd, info); - } - else - { - s->_raw_size = dynsymcount * sizeof (Elf_External_Versym); - s->contents = bfd_zalloc (output_bfd, s->_raw_size); - if (s->contents == NULL) - return FALSE; - - if (! elf_add_dynamic_entry (info, DT_VERSYM, 0)) - return FALSE; - } - - /* Set the size of the .dynsym and .hash sections. We counted - the number of dynamic symbols in elf_link_add_object_symbols. - We will build the contents of .dynsym and .hash when we build - the final symbol table, because until then we do not know the - correct value to give the symbols. We built the .dynstr - section as we went along in elf_link_add_object_symbols. */ - s = bfd_get_section_by_name (dynobj, ".dynsym"); - BFD_ASSERT (s != NULL); - s->_raw_size = dynsymcount * sizeof (Elf_External_Sym); - s->contents = bfd_alloc (output_bfd, s->_raw_size); - if (s->contents == NULL && s->_raw_size != 0) - return FALSE; - - if (dynsymcount != 0) - { - Elf_Internal_Sym isym; - - /* The first entry in .dynsym is a dummy symbol. */ - isym.st_value = 0; - isym.st_size = 0; - isym.st_name = 0; - isym.st_info = 0; - isym.st_other = 0; - isym.st_shndx = 0; - elf_swap_symbol_out (output_bfd, &isym, s->contents, 0); - } - - /* Compute the size of the hashing table. As a side effect this - computes the hash values for all the names we export. */ - bucketcount = compute_bucket_count (info); - - s = bfd_get_section_by_name (dynobj, ".hash"); - BFD_ASSERT (s != NULL); - hash_entry_size = elf_section_data (s)->this_hdr.sh_entsize; - s->_raw_size = ((2 + bucketcount + dynsymcount) * hash_entry_size); - s->contents = bfd_zalloc (output_bfd, s->_raw_size); - if (s->contents == NULL) - return FALSE; - - bfd_put (8 * hash_entry_size, output_bfd, bucketcount, s->contents); - bfd_put (8 * hash_entry_size, output_bfd, dynsymcount, - s->contents + hash_entry_size); - - elf_hash_table (info)->bucketcount = bucketcount; - - s = bfd_get_section_by_name (dynobj, ".dynstr"); - BFD_ASSERT (s != NULL); - - elf_finalize_dynstr (output_bfd, info); - - s->_raw_size = _bfd_elf_strtab_size (elf_hash_table (info)->dynstr); - - for (dtagcount = 0; dtagcount <= info->spare_dynamic_tags; ++dtagcount) - if (! elf_add_dynamic_entry (info, DT_NULL, 0)) - return FALSE; - } - - return TRUE; -} - -/* This function is used to adjust offsets into .dynstr for - dynamic symbols. This is called via elf_link_hash_traverse. */ - -static bfd_boolean -elf_adjust_dynstr_offsets (struct elf_link_hash_entry *h, void *data) -{ - struct elf_strtab_hash *dynstr = data; - - if (h->root.type == bfd_link_hash_warning) - h = (struct elf_link_hash_entry *) h->root.u.i.link; - - if (h->dynindx != -1) - h->dynstr_index = _bfd_elf_strtab_offset (dynstr, h->dynstr_index); - return TRUE; -} - -/* Assign string offsets in .dynstr, update all structures referencing - them. */ - -static bfd_boolean -elf_finalize_dynstr (bfd *output_bfd, struct bfd_link_info *info) -{ - struct elf_link_local_dynamic_entry *entry; - struct elf_strtab_hash *dynstr = elf_hash_table (info)->dynstr; - bfd *dynobj = elf_hash_table (info)->dynobj; - asection *sdyn; - bfd_size_type size; - Elf_External_Dyn *dyncon, *dynconend; - - _bfd_elf_strtab_finalize (dynstr); - size = _bfd_elf_strtab_size (dynstr); - - /* Update all .dynamic entries referencing .dynstr strings. */ - sdyn = bfd_get_section_by_name (dynobj, ".dynamic"); - BFD_ASSERT (sdyn != NULL); - - dyncon = (Elf_External_Dyn *) sdyn->contents; - dynconend = (Elf_External_Dyn *) (sdyn->contents + - sdyn->_raw_size); - for (; dyncon < dynconend; dyncon++) - { - Elf_Internal_Dyn dyn; - - elf_swap_dyn_in (dynobj, dyncon, & dyn); - switch (dyn.d_tag) - { - case DT_STRSZ: - dyn.d_un.d_val = size; - elf_swap_dyn_out (dynobj, & dyn, dyncon); - break; - case DT_NEEDED: - case DT_SONAME: - case DT_RPATH: - case DT_RUNPATH: - case DT_FILTER: - case DT_AUXILIARY: - dyn.d_un.d_val = _bfd_elf_strtab_offset (dynstr, dyn.d_un.d_val); - elf_swap_dyn_out (dynobj, & dyn, dyncon); - break; - default: - break; - } - } - - /* Now update local dynamic symbols. */ - for (entry = elf_hash_table (info)->dynlocal; entry ; entry = entry->next) - entry->isym.st_name = _bfd_elf_strtab_offset (dynstr, - entry->isym.st_name); - - /* And the rest of dynamic symbols. */ - elf_link_hash_traverse (elf_hash_table (info), - elf_adjust_dynstr_offsets, dynstr); - - /* Adjust version definitions. */ - if (elf_tdata (output_bfd)->cverdefs) - { - asection *s; - bfd_byte *p; - bfd_size_type i; - Elf_Internal_Verdef def; - Elf_Internal_Verdaux defaux; - - s = bfd_get_section_by_name (dynobj, ".gnu.version_d"); - p = (bfd_byte *) s->contents; - do - { - _bfd_elf_swap_verdef_in (output_bfd, (Elf_External_Verdef *) p, - &def); - p += sizeof (Elf_External_Verdef); - for (i = 0; i < def.vd_cnt; ++i) - { - _bfd_elf_swap_verdaux_in (output_bfd, - (Elf_External_Verdaux *) p, &defaux); - defaux.vda_name = _bfd_elf_strtab_offset (dynstr, - defaux.vda_name); - _bfd_elf_swap_verdaux_out (output_bfd, - &defaux, (Elf_External_Verdaux *) p); - p += sizeof (Elf_External_Verdaux); - } - } - while (def.vd_next); - } - - /* Adjust version references. */ - if (elf_tdata (output_bfd)->verref) - { - asection *s; - bfd_byte *p; - bfd_size_type i; - Elf_Internal_Verneed need; - Elf_Internal_Vernaux needaux; - - s = bfd_get_section_by_name (dynobj, ".gnu.version_r"); - p = (bfd_byte *) s->contents; - do - { - _bfd_elf_swap_verneed_in (output_bfd, (Elf_External_Verneed *) p, - &need); - need.vn_file = _bfd_elf_strtab_offset (dynstr, need.vn_file); - _bfd_elf_swap_verneed_out (output_bfd, &need, - (Elf_External_Verneed *) p); - p += sizeof (Elf_External_Verneed); - for (i = 0; i < need.vn_cnt; ++i) - { - _bfd_elf_swap_vernaux_in (output_bfd, - (Elf_External_Vernaux *) p, &needaux); - needaux.vna_name = _bfd_elf_strtab_offset (dynstr, - needaux.vna_name); - _bfd_elf_swap_vernaux_out (output_bfd, - &needaux, - (Elf_External_Vernaux *) p); - p += sizeof (Elf_External_Vernaux); - } - } - while (need.vn_next); - } - - return TRUE; -} - /* Final phase of ELF linker. */ /* A structure we use to avoid passing large numbers of arguments. */ @@ -5800,51 +3304,6 @@ elf_gc_common_final_link (bfd *abfd, struct bfd_link_info *info) return elf_bfd_final_link (abfd, info); } -/* This function will be called though elf_link_hash_traverse to store - all hash value of the exported symbols in an array. */ - -static bfd_boolean -elf_collect_hash_codes (struct elf_link_hash_entry *h, void *data) -{ - unsigned long **valuep = data; - const char *name; - char *p; - unsigned long ha; - char *alc = NULL; - - if (h->root.type == bfd_link_hash_warning) - h = (struct elf_link_hash_entry *) h->root.u.i.link; - - /* Ignore indirect symbols. These are added by the versioning code. */ - if (h->dynindx == -1) - return TRUE; - - name = h->root.root.string; - p = strchr (name, ELF_VER_CHR); - if (p != NULL) - { - alc = bfd_malloc (p - name + 1); - memcpy (alc, name, p - name); - alc[p - name] = '\0'; - name = alc; - } - - /* Compute the hash value. */ - ha = bfd_elf_hash (name); - - /* Store the found hash value in the array given as the argument. */ - *(*valuep)++ = ha; - - /* And store it in the struct so that we can put it in the hash table - later. */ - h->elf_hash_value = ha; - - if (alc != NULL) - free (alc); - - return TRUE; -} - bfd_boolean elf_reloc_symbol_deleted_p (bfd_vma offset, void *cookie) { diff --git a/bfd/elfxx-ia64.c b/bfd/elfxx-ia64.c index 47b4eae338b..c1d6622006e 100644 --- a/bfd/elfxx-ia64.c +++ b/bfd/elfxx-ia64.c @@ -192,7 +192,7 @@ static bfd_boolean elfNN_ia64_fake_sections static void elfNN_ia64_final_write_processing PARAMS ((bfd *abfd, bfd_boolean linker)); static bfd_boolean elfNN_ia64_add_symbol_hook - PARAMS ((bfd *abfd, struct bfd_link_info *info, const Elf_Internal_Sym *sym, + PARAMS ((bfd *abfd, struct bfd_link_info *info, Elf_Internal_Sym *sym, const char **namep, flagword *flagsp, asection **secp, bfd_vma *valp)); static int elfNN_ia64_additional_program_headers @@ -1430,7 +1430,7 @@ static bfd_boolean elfNN_ia64_add_symbol_hook (abfd, info, sym, namep, flagsp, secp, valp) bfd *abfd; struct bfd_link_info *info; - const Elf_Internal_Sym *sym; + Elf_Internal_Sym *sym; const char **namep ATTRIBUTE_UNUSED; flagword *flagsp ATTRIBUTE_UNUSED; asection **secp; @@ -3083,7 +3083,7 @@ elfNN_ia64_size_dynamic_sections (output_bfd, info) /* The DT_DEBUG entry is filled in by the dynamic linker and used by the debugger. */ #define add_dynamic_entry(TAG, VAL) \ - bfd_elfNN_add_dynamic_entry (info, (bfd_vma) (TAG), (bfd_vma) (VAL)) + _bfd_elf_add_dynamic_entry (info, TAG, VAL) if (!add_dynamic_entry (DT_DEBUG, 0)) return FALSE; diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c index 76b37326aba..12eb566941f 100644 --- a/bfd/elfxx-mips.c +++ b/bfd/elfxx-mips.c @@ -564,17 +564,8 @@ static bfd *reldyn_sorting_bfd; : bfd_put_32 (abfd, val, ptr)) /* Add a dynamic symbol table-entry. */ -#ifdef BFD64 -#define MIPS_ELF_ADD_DYNAMIC_ENTRY(info, tag, val) \ - (ABI_64_P (elf_hash_table (info)->dynobj) \ - ? bfd_elf64_add_dynamic_entry (info, tag, val) \ - : bfd_elf32_add_dynamic_entry (info, tag, val)) -#else #define MIPS_ELF_ADD_DYNAMIC_ENTRY(info, tag, val) \ - (ABI_64_P (elf_hash_table (info)->dynobj) \ - ? (abort (), FALSE) \ - : bfd_elf32_add_dynamic_entry (info, tag, val)) -#endif + _bfd_elf_add_dynamic_entry (info, tag, val) #define MIPS_ELF_RTYPE_TO_HOWTO(abfd, rtype, rela) \ (get_elf_backend_data (abfd)->elf_backend_mips_rtype_to_howto (rtype, rela)) @@ -4724,7 +4715,7 @@ _bfd_mips_elf_section_from_bfd_section (bfd *abfd ATTRIBUTE_UNUSED, bfd_boolean _bfd_mips_elf_add_symbol_hook (bfd *abfd, struct bfd_link_info *info, - const Elf_Internal_Sym *sym, const char **namep, + Elf_Internal_Sym *sym, const char **namep, flagword *flagsp ATTRIBUTE_UNUSED, asection **secp, bfd_vma *valp) { diff --git a/bfd/elfxx-mips.h b/bfd/elfxx-mips.h index 9e5d7afe427..0a684d90867 100644 --- a/bfd/elfxx-mips.h +++ b/bfd/elfxx-mips.h @@ -1,5 +1,5 @@ /* MIPS ELF specific backend routines. - Copyright 2002, 2003 Free Software Foundation, Inc. + Copyright 2002, 2003, 2004 Free Software Foundation, Inc. This file is part of BFD, the Binary File Descriptor library. @@ -35,7 +35,7 @@ extern bfd_boolean _bfd_mips_elf_fake_sections extern bfd_boolean _bfd_mips_elf_section_from_bfd_section (bfd *, asection *, int *); extern bfd_boolean _bfd_mips_elf_add_symbol_hook - (bfd *, struct bfd_link_info *, const Elf_Internal_Sym *, + (bfd *, struct bfd_link_info *, Elf_Internal_Sym *, const char **, flagword *, asection **, bfd_vma *); extern bfd_boolean _bfd_mips_elf_link_output_symbol_hook (struct bfd_link_info *, const char *, Elf_Internal_Sym *, diff --git a/bfd/elfxx-target.h b/bfd/elfxx-target.h index 5bf8f4d31d6..8dfd56a68fe 100644 --- a/bfd/elfxx-target.h +++ b/bfd/elfxx-target.h @@ -189,6 +189,9 @@ #ifndef bfd_elfNN_bfd_link_hash_table_create #define bfd_elfNN_bfd_link_hash_table_create _bfd_elf_link_hash_table_create #endif +#ifndef bfd_elfNN_bfd_link_add_symbols +#define bfd_elfNN_bfd_link_add_symbols bfd_elf_link_add_symbols +#endif #else /* ! defined (elf_backend_relocate_section) */ /* If no backend relocate_section routine, use the generic linker. Note - this will prevent the port from being able to use some of diff --git a/bfd/mpw-config.in b/bfd/mpw-config.in deleted file mode 100644 index 31addeebdcf..00000000000 --- a/bfd/mpw-config.in +++ /dev/null @@ -1,86 +0,0 @@ -# Configuration fragment for BFD. - -# This is almost always correct. - -Set selarchs "&bfd_{target_cpu}_arch" -Set defvec "" -Set selvecs "" -Set havevecs "" - -If "{target_canonical}" =~ /m68k-apple-macos/ - Set BFD_BACKENDS '"{o}"coff-m68k.c.o "{o}"cofflink.c.o' - Set defvec m68kcoff_vec - Set selvecs '&m68kcoff_vec' - Set havevecs '-d HAVE_m68kcoff_vec' - -Else If "{target_canonical}" =~ /powerpc-apple-macos/ - Set BFD_BACKENDS '"{o}"coff-pmac.c.o "{o}"xcofflink.c.o' - Set defvec pmac_xcoff_vec - Set selvecs '&pmac_xcoff_vec' - Set havevecs '-d HAVE_pmac_xcoff_vec' - Set selarchs "&bfd_powerpc_arch" - -Else If "{target_canonical}" =~ /i386-\Option-x-go32/ - Set BFD_BACKENDS '"{o}"coff-i386.c.o' - Set defvec i386coff_vec - Set selvecs '&i386coff_vec' - Set havevecs '-d HAVE_i386coff_vec' - -Else If "{target_canonical}" =~ /mips-\Option-x-\Option-x/ - Set BFD_BACKENDS '"{o}"coff-mips.c.o "{o}"ecoff.c.o "{o}"ecofflink.c.o "{o}"elf32.c.o "{o}"elf32-mips.c.o "{o}"elflink.c.o' - Set defvec ecoff_big_vec - Set selvecs '&ecoff_big_vec,&ecoff_little_vec,&bfd_elf32_bigmips_vec' - Set havevecs '-d HAVE_ecoff_big_vec -d HAVE_ecoff_little_vec -d HAVE_bfd_elf32_bigmips_vec' - -Else If "{target_canonical}" =~ /sh-\Option-x-hms/ - Set BFD_BACKENDS '"{o}"coff-sh.c.o "{o}"cofflink.c.o' - Set defvec shcoff_vec - Set selvecs '&shcoff_vec,&shlcoff_vec' - Set havevecs '-d HAVE_shcoff_vec -d HAVE_shlcoff_vec' -End If - -Set ta `echo {selarchs} | sed -e 's/&bfd_/{o}cpu-/g' -e 's/_arch/.c.o/g'` - -Set tdefaults "-d DEFAULT_VECTOR={defvec} -d SELECT_VECS={selvecs} -d SELECT_ARCHITECTURES={selarchs} {havevecs}" - -Echo '# From mpw-config.in' > "{o}"mk.tmp -Echo 'WORDSIZE = 32' >> "{o}"mk.tmp -Echo 'BFD_MACHINES = ' {ta} >> "{o}"mk.tmp -Echo 'BFD_BACKENDS = ' {BFD_BACKENDS} >> "{o}"mk.tmp -Echo 'TDEFAULTS = ' {tdefaults} >> "{o}"mk.tmp -Echo 'HDEPFILES = ' >> "{o}"mk.tmp -Echo 'TDEPFILES = ' >> "{o}"mk.tmp -Echo '# End from mpw-config.in' >> "{o}"mk.tmp - -Echo '/* config.h. Generated by mpw-configure. */' > "{o}"config.new -Echo '#include "mpw.h"' >> "{o}"config.new - -MoveIfChange "{o}"config.new "{o}"config.h - -# We can only handle 32-bit targets right now. - -sed -e 's/@WORDSIZE@/32/' \Option-d - -e 's/@wordsize@/32/' \Option-d - -e "s/@VERSION@/`Catenate {srcdir}VERSION`/" \Option-d - -e 's/@BFD_HOST_64_BIT_DEFINED@/0/' \Option-d - -e 's/@BFD_HOST_64_BIT@//' \Option-d - -e 's/@BFD_HOST_U_64_BIT@//' \Option-d - -e 's/@BFD_HOST_64BIT_LONG@/0/' \Option-d - "{srcdir}"bfd-in2.h >"{o}"bfd.h-new - -MoveIfChange "{o}"bfd.h-new "{o}"bfd.h - -sed -e 's/NN/32/g' "{srcdir}"elfxx-target.h >"{o}"elf32-target.h-new -MoveIfChange "{o}"elf32-target.h-new "{o}"elf32-target.h - -# Pre-expand some macros in coffswap.h, so MPW C doesn't choke. - -sed -e 's/^ PUT_AOUTHDR_TSIZE (/ bfd_h_put_32 (/' \Option-d - -e 's/^ PUT_AOUTHDR_DSIZE (/ bfd_h_put_32 (/' \Option-d - -e 's/^ PUT_AOUTHDR_BSIZE (/ bfd_h_put_32 (/' \Option-d - -e 's/^ PUT_AOUTHDR_ENTRY (/ bfd_h_put_32 (/' \Option-d - -e 's/^ PUT_AOUTHDR_TEXT_START (/ bfd_h_put_32 (/' \Option-d - -e 's/^ PUT_AOUTHDR_DATA_START (/ bfd_h_put_32 (/' \Option-d - "{srcdir}"coffswap.h >"{o}"coffswap.h-new - -MoveIfChange "{o}"coffswap.h-new "{o}"coffswap.h diff --git a/bfd/mpw-make.sed b/bfd/mpw-make.sed deleted file mode 100644 index b2463c72b7f..00000000000 --- a/bfd/mpw-make.sed +++ /dev/null @@ -1,81 +0,0 @@ -# Sed commands to finish translating the Unix BFD Makefile into MPW syntax. - -# Whack out unused host and target define bits. -/HDEFINES/s/@HDEFINES@// -/TDEFINES/s/@TDEFINES@// - -# Fix pathnames to include directories. -/^INCDIR = /s/^INCDIR = .*$/INCDIR = "{topsrcdir}"include/ -/^CSEARCH = /s/$/ -i "{INCDIR}":mpw: -i ::extra-include:/ - -# Comment out setting of vars, configure script will add these itself. -/^WORDSIZE =/s/^/#/ -# /^ALL_BACKENDS/s/^/#/ -/^BFD_BACKENDS/s/^/#/ -/^BFD_MACHINES/s/^/#/ -/^TDEFAULTS/s/^/#/ - -# Remove extra, useless, "all". -/^all \\Option-f _oldest/,/^$/d - -# Remove the Makefile rebuild rule. -/^Makefile /,/--recheck/d - -# Don't do any recursive subdir stuff. -/ subdir_do/s/{MAKE}/null-command/ - -/BFD_H/s/^{BFD_H}/#{BFD_H}/ - -# Add explicit srcdir paths to special files. -/config.bfd/s/ config.bfd/ "{s}"config.bfd/g -/targmatch.sed/s/ targmatch.sed/ "{s}"targmatch.sed/g - -# Point at include files that are always in the objdir. -/bfd/s/"{s}"bfd\.h/"{o}"bfd.h/g -/config/s/"{s}"config\.h/"{o}"config.h/g -/targmatch/s/"{s}"targmatch\.h/"{o}"targmatch.h/g -/targmatch/s/^targmatch\.h/"{o}"targmatch.h/ -/elf32-target/s/"{s}"elf32-target\.h/"{o}"elf32-target.h/g -/elf32-target/s/^elf32-target\.h/"{o}"elf32-target.h/ -/elf64-target/s/"{s}"elf64-target\.h/"{o}"elf64-target.h/g -/elf64-target/s/^elf64-target\.h/"{o}"elf64-target.h/ - -/"{s}"{INCDIR}/s/"{s}"{INCDIR}/"{INCDIR}"/g - -/dep/s/\.dep/__dep/g - -# Removing duplicates is cool but presently unnecessary, -# so whack this out. -/^ofiles \\Option-f/,/^$/d -/ofiles/s/{OFILES} ofiles/{OFILES}/ -/echo ofiles = /d -/cat ofiles/s/`cat ofiles`/{OFILES}/ - -# No corefile support. -/COREFILE/s/@COREFILE@// -/COREFLAG/s/@COREFLAG@// - -# No PIC foolery in this environment. -/@ALLLIBS@/s/@ALLLIBS@/{TARGETLIB}/ -/@PICLIST@/s/@PICLIST@// -/@PICFLAG@/s/@PICFLAG@// -/^{OFILES} \\Option-f stamp-picdir/,/^$/d - -# Remove the pic trickery from the default build rule. -/^\.c\.o \\Option-f /,/End If/c\ -.c.o \\Option-f .c - -# MPW Make doesn't know about $<. -/"{o}"targets.c.o \\Option-f "{s}"targets.c Makefile/,/^$/c\ -"{o}"targets.c.o \\Option-f "{s}"targets.c Makefile\ - {CC} @DASH_C_FLAG@ {ALL_CFLAGS} {TDEFAULTS} "{s}"targets.c -o "{o}"targets.c.o - -/"{o}"archures.c.o \\Option-f "{s}"archures.c Makefile/,/^$/c\ -"{o}"archures.c.o \\Option-f "{s}"archures.c Makefile\ - {CC} @DASH_C_FLAG@ {ALL_CFLAGS} {TDEFAULTS} "{s}"archures.c -o "{o}"archures.c.o - -# Remove the .h rebuilding rules, we don't currently have a doc subdir, -# or a way to build the prototype-hacking tool that's in it. -/^"{srcdir}"bfd-in2.h \\Option-f /,/^$/d -/^"{srcdir}"libbfd.h \\Option-f /,/^$/d -/^"{srcdir}"libcoff.h \\Option-f /,/^$/d diff --git a/bfd/version.h b/bfd/version.h index 2b599705011..16afdadee71 100644 --- a/bfd/version.h +++ b/bfd/version.h @@ -1,3 +1,3 @@ -#define BFD_VERSION_DATE 20040324 +#define BFD_VERSION_DATE 20040327 #define BFD_VERSION @bfd_version@ #define BFD_VERSION_STRING @bfd_version_string@ diff --git a/configure b/configure index a884c3281bf..a674ab6b6fa 100755 --- a/configure +++ b/configure @@ -4484,9 +4484,9 @@ else enable_werror=yes fi -case ${enable_error} in - yes) WERROR=-Werror ;; - *) WERROR= ;; +case ${enable_werror} in + yes) stage2_werror_flag="--enable-werror-always" ;; + *) stage2_werror_flag="" ;; esac @@ -4745,7 +4745,7 @@ s%@MAINTAINER_MODE_TRUE@%$MAINTAINER_MODE_TRUE%g s%@MAINTAINER_MODE_FALSE@%$MAINTAINER_MODE_FALSE%g s%@MAINT@%$MAINT%g s%@stage1_cflags@%$stage1_cflags%g -s%@WERROR@%$WERROR%g +s%@stage2_werror_flag@%$stage2_werror_flag%g CEOF EOF diff --git a/configure.in b/configure.in index 0a9f05fd8fc..5735d84c8b4 100644 --- a/configure.in +++ b/configure.in @@ -2129,10 +2129,10 @@ AC_SUBST(stage1_cflags) AC_ARG_ENABLE(werror, [ --enable-werror enable -Werror in bootstrap stage2 and later], [], [enable_werror=yes]) -case ${enable_error} in - yes) WERROR=-Werror ;; - *) WERROR= ;; +case ${enable_werror} in + yes) stage2_werror_flag="--enable-werror-always" ;; + *) stage2_werror_flag="" ;; esac -AC_SUBST(WERROR) +AC_SUBST(stage2_werror_flag) AC_OUTPUT(Makefile) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 9eb781581ea..fc634276c9e 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,76 @@ +2004-02-26 J. Brobecker <brobecker@gnat.com> + + * amd64-tdep.c (amd64_classify): make RANGE_TYPE objects be part + of the INTEGER class. + +2004-03-26 Jim Blandy <jimb@redhat.com> + + * ppc-linux-tdep.c (ppc_linux_init_abi): Long doubles are eight + bytes long on PPC GNU/Linux. + +2004-03-26 David Carlton <carlton@kealia.com> + + * PROBLEMS: Refer to gdb/1588 instead of gdb/826. + +2004-03-25 Andrew Cagney <cagney@redhat.com> + + * PROBLEMS: Add general section titles, remove references to + specific releases. + +2004-03-25 Daniel Jacobowitz <drow@mvista.com> + + * arm-linux-tdep.c (ARM_LINUX_JB_ELEMENT_SIZE): Define to + INT_REGISTER_SIZE. + (arm_linux_push_arguments): Use TARGET_DOUBLE_BIT instead of + FP_REGISTER_VIRTUAL_SIZE. + * arm-tdep.c (arm_make_sigtramp_cache): Use register_size instead + of DEPRECATED_REGISTER_RAW_SIZE. + (arm_register_type): Add gdbarch argument. + (arm_register_raw_size, arm_register_virtual_size): Delete. + (arm_register_byte, arm_extract_return_value) + (arm_store_return_value, arm_get_longjmp_target): Update references + to INT_REGISTER_RAW_SIZE and FP_REGISTER_RAW_SIZE. + (arm_gdbarch_init): Likewise. Don't set + deprecated_register_raw_size, deprecated_register_virtual_size, + deprecated_max_register_raw_size, + deprecated_max_register_virtual_size, or + deprecated_max_register_virtual_type. Do set register_type. + * arm-tdep.h (ARM_MAX_REGISTER_RAW_SIZE) + (ARM_MAX_REGISTER_VIRTUAL_SIZE, INT_REGISTER_VIRTUAL_SIZE) + (FP_REGISTER_VIRTUAL_SIZE): Delete. + (INT_REGISTER_RAW_SIZE): Rename to INT_REGISTER_SIZE. + (FP_REGISTER_RAW_SIZE): Rename to FP_REGISTER_SIZE. + * arm-linux-tdep.c (ARM_NBSD_JB_ELEMENT_SIZE): Define to + INT_REGISTER_SIZE. + * remote-rdp.c (remote_rdp_fetch_register): Use MAX_REGISTER_SIZE. + (remote_rdp_store_register): Likewise. + +2004-03-24 Daniel Jacobowitz <drow@mvista.com> + + * Makefile.in (mips-linux-tdep.o): Update dependencies. + * mips-tdep.c (mips_gdbarch_init): Move frame predicates + to after osabi initialization. + * mips-linux-tdep.c: Include "trad-frame.h" and "tramp-frame.h". + (mips_linux_o32_sigframe_init, mips_linux_n32n64_sigframe_init): New + functions. + (mips_linux_o32_sigframe, mips_linux_o32_rt_sigframe) + (mips_linux_n32_rt_sigframe, mips_linux_n64_rt_sigframe): New + variables. + (mips_linux_init_abi): Append signal trampoline unwinders. + +2004-03-24 Andrew Cagney <cagney@redhat.com> + + * tramp-frame.h (TRAMP_SENTINEL_INSN): Define, document. + * tramp-frame.c: Include "gdb_assert.h". + (tramp_frame_start): Use TRAMP_SENTINEL_INSN. Use ULONGEST and + correct sizeof. + (tramp_frame_append): Validate the tramp frame's instructions. + * Makefile.in (tramp-frame.o): Update dependencies. + +2004-03-23 Andrew Cagney <cagney@redhat.com> + + * trad-frame.h (trad_frame_set_reg_addr): Declare. + 2004-03-23 Andrew Cagney <cagney@redhat.com> * MAINTAINERS (Past Maintainers): Add Mark Salter and Fernando diff --git a/gdb/Makefile.in b/gdb/Makefile.in index e2105e58b4b..b78d46cd7fb 100644 --- a/gdb/Makefile.in +++ b/gdb/Makefile.in @@ -2052,7 +2052,7 @@ mips-irix-tdep.o: mips-irix-tdep.c $(defs_h) $(osabi_h) $(elf_bfd_h) mips-linux-nat.o: mips-linux-nat.c $(defs_h) $(mips_tdep_h) mips-linux-tdep.o: mips-linux-tdep.c $(defs_h) $(gdbcore_h) $(target_h) \ $(solib_svr4_h) $(osabi_h) $(mips_tdep_h) $(gdb_string_h) \ - $(gdb_assert_h) $(frame_h) + $(gdb_assert_h) $(frame_h) $(trad_frame_h) $(tramp_frame_h) mips-nat.o: mips-nat.c $(defs_h) $(inferior_h) $(gdbcore_h) $(regcache_h) mipsnbsd-nat.o: mipsnbsd-nat.c $(defs_h) $(inferior_h) $(regcache_h) \ $(mipsnbsd_tdep_h) diff --git a/gdb/PROBLEMS b/gdb/PROBLEMS index 5455f22bb01..901b0d29a04 100644 --- a/gdb/PROBLEMS +++ b/gdb/PROBLEMS @@ -3,23 +3,17 @@ See also: http://www.gnu.org/software/gdb/bugs/ -mips*-*-* -powerpc*-*-* -sparc*-*-* -GDB's SPARC, MIPS and PowerPC targets, in 6.0, have not been updated -to use the new frame mechanism. +*** Misc -People encountering problems with these targets should consult GDB's -web pages and mailing lists (http://www.gnu.org/software/gdb/) to see -if there is an update. - -*** Regressions since gdb 6.0 +gdb/1560: Control-C does not always interrupt GDB. -gdb/826: variables in C++ namespaces have to be enclosed in quotes +When GDB is busy processing a command which takes a long time to +complete, hitting Control-C does not have the expected effect. +The command execution is not aborted, and the "QUIT" message confirming +the abortion is displayed only after the command has been completed. -When referring to a variable in C++ code that is inside a -namespace, you have to put it inside single quotes. +*** C++ support gdb/931: GDB could be more generous when reading types C++ templates on input @@ -27,11 +21,6 @@ When the user types a template, GDB frequently requires the type to be typed in a certain way (e.g. "const char*" as opposed to "const char *" or "char const *" or "char const*"). -gdb/1505: [regression] gdb prints a bad backtrace for a thread - -When backtracing a thread, gdb doesn't stop until it hits garbage. -This is sensitive to the operating system and thread library. - gdb/1512: no canonical way to output names of C++ types We currently don't have any canonical way to output names of C++ types. @@ -50,14 +39,17 @@ This applies only to classes where the class type is defined inside a function, not to variables defined with types that are defined somewhere outside any function (which most types are). -gdb/1560: Control-C does not always interrupt GDB. - -When GDB is busy processing a command which takes a long time to -complete, hitting Control-C does not have the expected effect. -The command execution is not aborted, and the "QUIT" message confirming -the abortion is displayed only after the command has been completed. +gdb/1588: names of c++ nested types in casts must be enclosed in quotes -*** Regressions since gdb 5.3 +You must type + (gdb) print ('Foo::Bar') x +or + (gdb) print ('Foo::Bar' *) y +instead of + (gdb) print (Foo::Bar) x +or + (gdb) print (Foo::Bar *) y +respectively. gdb/1091: Constructor breakpoints ignored gdb/1193: g++ 3.3 creates multiple constructors: gdb 5.3 can't set breakpoints @@ -76,3 +68,29 @@ implement virtual base classes. gcc 2.x generated just one object code function with a hidden parameter, but gcc 3.x conforms to a multi-vendor ABI for C++ which requires multiple object code functions. +*** Stack backtraces + +gdb/1505: [regression] gdb prints a bad backtrace for a thread + +When backtracing a thread, gdb doesn't stop until it hits garbage. +This is sensitive to the operating system and thread library. + +mips*-*-* +powerpc*-*-* +sparc*-*-* + +GDB's SPARC, MIPS and PowerPC targets, in 6.0, have not been updated +to use the new frame mechanism. + +People encountering problems with these targets should consult GDB's +web pages and mailing lists (http://www.gnu.org/software/gdb/) to see +if there is an update. + +arm-*-* + +GDB's ARM target, in 6.0, has not been updated to use the new frame +mechanism. + +Fortunately the ARM target, in the GDB's mainline sources, has been +updated so people encountering problems should consider downloading a +more current GDB (http://www.gnu.org/software/gdb/current). diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c index 6d291632618..1a66e45b4fe 100644 --- a/gdb/amd64-tdep.c +++ b/gdb/amd64-tdep.c @@ -371,8 +371,11 @@ amd64_classify (struct type *type, enum amd64_reg_class class[2]) class[0] = class[1] = AMD64_NO_CLASS; /* Arguments of types (signed and unsigned) _Bool, char, short, int, - long, long long, and pointers are in the INTEGER class. */ + long, long long, and pointers are in the INTEGER class. Similarly, + range types, used by languages such as Ada, are also in the INTEGER + class. */ if ((code == TYPE_CODE_INT || code == TYPE_CODE_ENUM + || code == TYPE_CODE_RANGE || code == TYPE_CODE_PTR || code == TYPE_CODE_REF) && (len == 1 || len == 2 || len == 4 || len == 8)) class[0] = AMD64_INTEGER; diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c index 42d4438d55d..26b1a173320 100644 --- a/gdb/arm-linux-tdep.c +++ b/gdb/arm-linux-tdep.c @@ -59,7 +59,7 @@ LONGEST arm_linux_call_dummy_words[] = }; /* Description of the longjmp buffer. */ -#define ARM_LINUX_JB_ELEMENT_SIZE INT_REGISTER_RAW_SIZE +#define ARM_LINUX_JB_ELEMENT_SIZE INT_REGISTER_SIZE #define ARM_LINUX_JB_PC 21 /* Extract from an array REGBUF containing the (raw) register state @@ -130,7 +130,7 @@ arm_linux_push_arguments (int nargs, struct value **args, CORE_ADDR sp, /* ANSI C code passes float arguments as integers, K&R code passes float arguments as doubles. Correct for this here. */ if (TYPE_CODE_FLT == TYPE_CODE (arg_type) && DEPRECATED_REGISTER_SIZE == len) - nstack_size += FP_REGISTER_VIRTUAL_SIZE; + nstack_size += TARGET_DOUBLE_BIT / TARGET_CHAR_BIT; else nstack_size += len; } diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 91a200d77c7..3fa37c9a88e 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -1094,7 +1094,7 @@ arm_make_sigtramp_cache (struct frame_info *next_frame) cache->framereg = ARM_SP_REGNUM; cache->prev_sp = read_memory_integer (cache->saved_regs[cache->framereg].addr, - DEPRECATED_REGISTER_RAW_SIZE (cache->framereg)); + register_size (current_gdbarch, cache->framereg)); return cache; } @@ -1396,7 +1396,7 @@ arm_print_float_info (struct gdbarch *gdbarch, struct ui_file *file, register N. */ static struct type * -arm_register_type (int regnum) +arm_register_type (struct gdbarch *gdbarch, int regnum) { if (regnum >= ARM_F0_REGNUM && regnum < ARM_F0_REGNUM + NUM_FREGS) { @@ -1416,44 +1416,16 @@ static int arm_register_byte (int regnum) { if (regnum < ARM_F0_REGNUM) - return regnum * INT_REGISTER_RAW_SIZE; + return regnum * INT_REGISTER_SIZE; else if (regnum < ARM_PS_REGNUM) - return (NUM_GREGS * INT_REGISTER_RAW_SIZE - + (regnum - ARM_F0_REGNUM) * FP_REGISTER_RAW_SIZE); + return (NUM_GREGS * INT_REGISTER_SIZE + + (regnum - ARM_F0_REGNUM) * FP_REGISTER_SIZE); else - return (NUM_GREGS * INT_REGISTER_RAW_SIZE - + NUM_FREGS * FP_REGISTER_RAW_SIZE + return (NUM_GREGS * INT_REGISTER_SIZE + + NUM_FREGS * FP_REGISTER_SIZE + (regnum - ARM_FPS_REGNUM) * STATUS_REGISTER_SIZE); } -/* Number of bytes of storage in the actual machine representation for - register N. All registers are 4 bytes, except fp0 - fp7, which are - 12 bytes in length. */ - -static int -arm_register_raw_size (int regnum) -{ - if (regnum < ARM_F0_REGNUM) - return INT_REGISTER_RAW_SIZE; - else if (regnum < ARM_FPS_REGNUM) - return FP_REGISTER_RAW_SIZE; - else - return STATUS_REGISTER_SIZE; -} - -/* Number of bytes of storage in a program's representation - for register N. */ -static int -arm_register_virtual_size (int regnum) -{ - if (regnum < ARM_F0_REGNUM) - return INT_REGISTER_VIRTUAL_SIZE; - else if (regnum < ARM_FPS_REGNUM) - return FP_REGISTER_VIRTUAL_SIZE; - else - return STATUS_REGISTER_SIZE; -} - /* Map GDB internal REGNUM onto the Arm simulator register numbers. */ static int arm_register_sim_regno (int regnum) @@ -2082,7 +2054,7 @@ arm_extract_return_value (struct type *type, /* The value is in register F0 in internal format. We need to extract the raw value and then convert it to the desired internal type. */ - bfd_byte tmpbuf[FP_REGISTER_RAW_SIZE]; + bfd_byte tmpbuf[FP_REGISTER_SIZE]; regcache_cooked_read (regs, ARM_F0_REGNUM, tmpbuf); convert_from_extended (floatformat_from_type (type), tmpbuf, @@ -2095,7 +2067,7 @@ arm_extract_return_value (struct type *type, regcache_cooked_read (regs, ARM_A1_REGNUM, valbuf); if (TYPE_LENGTH (type) > 4) regcache_cooked_read (regs, ARM_A1_REGNUM + 1, - valbuf + INT_REGISTER_RAW_SIZE); + valbuf + INT_REGISTER_SIZE); break; default: @@ -2124,11 +2096,11 @@ arm_extract_return_value (struct type *type, anything special for small big-endian values. */ regcache_cooked_read_unsigned (regs, regno++, &tmp); store_unsigned_integer (valbuf, - (len > INT_REGISTER_RAW_SIZE - ? INT_REGISTER_RAW_SIZE : len), + (len > INT_REGISTER_SIZE + ? INT_REGISTER_SIZE : len), tmp); - len -= INT_REGISTER_RAW_SIZE; - valbuf += INT_REGISTER_RAW_SIZE; + len -= INT_REGISTER_SIZE; + valbuf += INT_REGISTER_SIZE; } } else @@ -2138,15 +2110,15 @@ arm_extract_return_value (struct type *type, registers with 32-bit load instruction(s). */ int len = TYPE_LENGTH (type); int regno = ARM_A1_REGNUM; - bfd_byte tmpbuf[INT_REGISTER_RAW_SIZE]; + bfd_byte tmpbuf[INT_REGISTER_SIZE]; while (len > 0) { regcache_cooked_read (regs, regno++, tmpbuf); memcpy (valbuf, tmpbuf, - len > INT_REGISTER_RAW_SIZE ? INT_REGISTER_RAW_SIZE : len); - len -= INT_REGISTER_RAW_SIZE; - valbuf += INT_REGISTER_RAW_SIZE; + len > INT_REGISTER_SIZE ? INT_REGISTER_SIZE : len); + len -= INT_REGISTER_SIZE; + valbuf += INT_REGISTER_SIZE; } } } @@ -2270,7 +2242,7 @@ arm_store_return_value (struct type *type, struct regcache *regs, if (TYPE_CODE (type) == TYPE_CODE_FLT) { - char buf[ARM_MAX_REGISTER_RAW_SIZE]; + char buf[MAX_REGISTER_SIZE]; switch (arm_get_fp_model (current_gdbarch)) { @@ -2285,7 +2257,7 @@ arm_store_return_value (struct type *type, struct regcache *regs, regcache_cooked_write (regs, ARM_A1_REGNUM, valbuf); if (TYPE_LENGTH (type) > 4) regcache_cooked_write (regs, ARM_A1_REGNUM + 1, - valbuf + INT_REGISTER_RAW_SIZE); + valbuf + INT_REGISTER_SIZE); break; default: @@ -2306,10 +2278,10 @@ arm_store_return_value (struct type *type, struct regcache *regs, { /* Values of one word or less are zero/sign-extended and returned in r0. */ - bfd_byte tmpbuf[INT_REGISTER_RAW_SIZE]; + bfd_byte tmpbuf[INT_REGISTER_SIZE]; LONGEST val = unpack_long (type, valbuf); - store_signed_integer (tmpbuf, INT_REGISTER_RAW_SIZE, val); + store_signed_integer (tmpbuf, INT_REGISTER_SIZE, val); regcache_cooked_write (regs, ARM_A1_REGNUM, tmpbuf); } else @@ -2323,8 +2295,8 @@ arm_store_return_value (struct type *type, struct regcache *regs, while (len > 0) { regcache_cooked_write (regs, regno++, valbuf); - len -= INT_REGISTER_RAW_SIZE; - valbuf += INT_REGISTER_RAW_SIZE; + len -= INT_REGISTER_SIZE; + valbuf += INT_REGISTER_SIZE; } } } @@ -2335,15 +2307,15 @@ arm_store_return_value (struct type *type, struct regcache *regs, registers with 32-bit load instruction(s). */ int len = TYPE_LENGTH (type); int regno = ARM_A1_REGNUM; - bfd_byte tmpbuf[INT_REGISTER_RAW_SIZE]; + bfd_byte tmpbuf[INT_REGISTER_SIZE]; while (len > 0) { memcpy (tmpbuf, valbuf, - len > INT_REGISTER_RAW_SIZE ? INT_REGISTER_RAW_SIZE : len); + len > INT_REGISTER_SIZE ? INT_REGISTER_SIZE : len); regcache_cooked_write (regs, regno++, tmpbuf); - len -= INT_REGISTER_RAW_SIZE; - valbuf += INT_REGISTER_RAW_SIZE; + len -= INT_REGISTER_SIZE; + valbuf += INT_REGISTER_SIZE; } } } @@ -2352,16 +2324,16 @@ static int arm_get_longjmp_target (CORE_ADDR *pc) { CORE_ADDR jb_addr; - char buf[INT_REGISTER_RAW_SIZE]; + char buf[INT_REGISTER_SIZE]; struct gdbarch_tdep *tdep = gdbarch_tdep (current_gdbarch); jb_addr = read_register (ARM_A1_REGNUM); if (target_read_memory (jb_addr + tdep->jb_pc * tdep->jb_elt_size, buf, - INT_REGISTER_RAW_SIZE)) + INT_REGISTER_SIZE)) return 0; - *pc = extract_unsigned_integer (buf, INT_REGISTER_RAW_SIZE); + *pc = extract_unsigned_integer (buf, INT_REGISTER_SIZE); return 1; } @@ -2805,15 +2777,11 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) set_gdbarch_pc_regnum (gdbarch, ARM_PC_REGNUM); set_gdbarch_deprecated_register_byte (gdbarch, arm_register_byte); set_gdbarch_deprecated_register_bytes (gdbarch, - (NUM_GREGS * INT_REGISTER_RAW_SIZE - + NUM_FREGS * FP_REGISTER_RAW_SIZE + (NUM_GREGS * INT_REGISTER_SIZE + + NUM_FREGS * FP_REGISTER_SIZE + NUM_SREGS * STATUS_REGISTER_SIZE)); set_gdbarch_num_regs (gdbarch, NUM_GREGS + NUM_FREGS + NUM_SREGS); - set_gdbarch_deprecated_register_raw_size (gdbarch, arm_register_raw_size); - set_gdbarch_deprecated_register_virtual_size (gdbarch, arm_register_virtual_size); - set_gdbarch_deprecated_max_register_raw_size (gdbarch, FP_REGISTER_RAW_SIZE); - set_gdbarch_deprecated_max_register_virtual_size (gdbarch, FP_REGISTER_VIRTUAL_SIZE); - set_gdbarch_deprecated_register_virtual_type (gdbarch, arm_register_type); + set_gdbarch_register_type (gdbarch, arm_register_type); /* Internal <-> external register number maps. */ set_gdbarch_register_sim_regno (gdbarch, arm_register_sim_regno); diff --git a/gdb/arm-tdep.h b/gdb/arm-tdep.h index 26f3a83a973..bb30455a314 100644 --- a/gdb/arm-tdep.h +++ b/gdb/arm-tdep.h @@ -45,24 +45,13 @@ enum gdb_regnum { ARM_LAST_FP_ARG_REGNUM = ARM_F3_REGNUM }; -/* Used in target-specific code when we need to know the size of the - largest type of register we need to handle. */ -#define ARM_MAX_REGISTER_RAW_SIZE 12 -#define ARM_MAX_REGISTER_VIRTUAL_SIZE 8 - /* Size of integer registers. */ -#define INT_REGISTER_RAW_SIZE 4 -#define INT_REGISTER_VIRTUAL_SIZE 4 +#define INT_REGISTER_SIZE 4 /* Say how long FP registers are. Used for documentation purposes and code readability in this header. IEEE extended doubles are 80 bits. DWORD aligned they use 96 bits. */ -#define FP_REGISTER_RAW_SIZE 12 - -/* GCC doesn't support long doubles (extended IEEE values). The FP - register virtual size is therefore 64 bits. Used for documentation - purposes and code readability in this header. */ -#define FP_REGISTER_VIRTUAL_SIZE 8 +#define FP_REGISTER_SIZE 12 /* Status registers are the same size as general purpose registers. Used for documentation purposes and code readability in this diff --git a/gdb/armnbsd-tdep.c b/gdb/armnbsd-tdep.c index 88cf2e52797..0ce46e653df 100644 --- a/gdb/armnbsd-tdep.c +++ b/gdb/armnbsd-tdep.c @@ -27,7 +27,7 @@ /* Description of the longjmp buffer. */ #define ARM_NBSD_JB_PC 24 -#define ARM_NBSD_JB_ELEMENT_SIZE INT_REGISTER_RAW_SIZE +#define ARM_NBSD_JB_ELEMENT_SIZE INT_REGISTER_SIZE /* For compatibility with previous implemenations of GDB on arm/NetBSD, override the default little-endian breakpoint. */ diff --git a/gdb/doc/ChangeLog b/gdb/doc/ChangeLog index 196c1fc598a..263538d2ea6 100644 --- a/gdb/doc/ChangeLog +++ b/gdb/doc/ChangeLog @@ -1,3 +1,10 @@ +2004-03-26 Andrew Cagney <cagney@redhat.com> + + * gdb.texinfo (TUI): Delete reference to --enable-tui. Mention + "gdbtui". + (Mode Options): Mention "gdbtui". Use "Text" not "Terminal". + (Contributors): Mention both Text and Terminal User Interface. + 2004-03-23 Andrew Cagney <cagney@redhat.com> * gdbint.texinfo (Target Architecture Definition): Deprecate diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index dac02de0ef2..19fa803a321 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -445,10 +445,10 @@ nearly innumerable bug fixes and cleanups throughout @value{GDBN}. The following people at the Hewlett-Packard Company contributed support for the PA-RISC 2.0 architecture, HP-UX 10.20, 10.30, and 11.0 (narrow mode), HP's implementation of kernel threads, HP's aC@t{++} -compiler, and the terminal user interface: Ben Krepp, Richard Title, -John Bishop, Susan Macchia, Kathy Mann, Satish Pai, India Paul, Steve -Rehrauer, and Elena Zannoni. Kim Haase provided HP-specific -information in this manual. +compiler, and the Text User Interface (nee Terminal User Interface): +Ben Krepp, Richard Title, John Bishop, Susan Macchia, Kathy Mann, +Satish Pai, India Paul, Steve Rehrauer, and Elena Zannoni. Kim Haase +provided HP-specific information in this manual. DJ Delorie ported @value{GDBN} to MS-DOS, for the DJGPP project. Robert Hoehne made significant contributions to the DJGPP port. @@ -1112,12 +1112,13 @@ Run using @var{device} for your program's standard input and output. @c resolve the situation of these eventually @item -tui @cindex @code{--tui} -Activate the Terminal User Interface when starting. -The Terminal User Interface manages several text windows on the terminal, -showing source, assembly, registers and @value{GDBN} command outputs -(@pxref{TUI, ,@value{GDBN} Text User Interface}). -Do not use this option if you run @value{GDBN} from Emacs -(@pxref{Emacs, ,Using @value{GDBN} under @sc{gnu} Emacs}). +Activate the @dfn{Text User Interface} when starting. The Text User +Interface manages several text windows on the terminal, showing +source, assembly, registers and @value{GDBN} command outputs +(@pxref{TUI, ,@value{GDBN} Text User Interface}). Alternatively, the +Text User Interface can be enabled by invoking the program +@samp{gdbtui}. Do not use this option if you run @value{GDBN} from +Emacs (@pxref{Emacs, ,Using @value{GDBN} under @sc{gnu} Emacs}). @c @item -xdb @c @cindex @code{--xdb} @@ -13888,6 +13889,7 @@ interpreter-exec mi "-data-list-register-names" @node TUI @chapter @value{GDBN} Text User Interface @cindex TUI +@cindex Text User Interface @menu * TUI Overview:: TUI overview @@ -13897,12 +13899,14 @@ interpreter-exec mi "-data-list-register-names" * TUI Configuration:: TUI configuration variables @end menu -The @value{GDBN} Text User Interface, TUI in short, -is a terminal interface which uses the @code{curses} library -to show the source file, the assembly output, the program registers -and @value{GDBN} commands in separate text windows. -The TUI is available only when @value{GDBN} is configured -with the @code{--enable-tui} configure option (@pxref{Configure Options}). +The @value{GDBN} Text User Interface, TUI in short, is a terminal +interface which uses the @code{curses} library to show the source +file, the assembly output, the program registers and @value{GDBN} +commands in separate text windows. + +The TUI is enabled by invoking @value{GDBN} using either +@pindex gdbtui +@samp{gdbtui} or @samp{gdb -tui}. @node TUI Overview @section TUI overview diff --git a/gdb/mips-linux-tdep.c b/gdb/mips-linux-tdep.c index 7e59eb1c5d3..48a82f7cf36 100644 --- a/gdb/mips-linux-tdep.c +++ b/gdb/mips-linux-tdep.c @@ -28,6 +28,8 @@ #include "gdb_string.h" #include "gdb_assert.h" #include "frame.h" +#include "trad-frame.h" +#include "tramp-frame.h" /* Copied from <asm/elf.h>. */ #define ELF_NGREG 45 @@ -797,6 +799,312 @@ mips_linux_skip_resolver (struct gdbarch *gdbarch, CORE_ADDR pc) return 0; } +/* Signal trampoline support. There are four supported layouts for a + signal frame: o32 sigframe, o32 rt_sigframe, n32 rt_sigframe, and + n64 rt_sigframe. We handle them all independently; not the most + efficient way, but simplest. First, declare all the unwinders. */ + +static void mips_linux_o32_sigframe_init (const struct tramp_frame *self, + struct frame_info *next_frame, + struct trad_frame_cache *this_cache, + CORE_ADDR func); + +static void mips_linux_n32n64_sigframe_init (const struct tramp_frame *self, + struct frame_info *next_frame, + struct trad_frame_cache *this_cache, + CORE_ADDR func); + +#define MIPS_NR_LINUX 4000 +#define MIPS_NR_N64_LINUX 5000 +#define MIPS_NR_N32_LINUX 6000 + +#define MIPS_NR_sigreturn MIPS_NR_LINUX + 119 +#define MIPS_NR_rt_sigreturn MIPS_NR_LINUX + 193 +#define MIPS_NR_N64_rt_sigreturn MIPS_NR_N64_LINUX + 211 +#define MIPS_NR_N32_rt_sigreturn MIPS_NR_N32_LINUX + 211 + +#define MIPS_INST_LI_V0_SIGRETURN 0x24020000 + MIPS_NR_sigreturn +#define MIPS_INST_LI_V0_RT_SIGRETURN 0x24020000 + MIPS_NR_rt_sigreturn +#define MIPS_INST_LI_V0_N64_RT_SIGRETURN 0x24020000 + MIPS_NR_N64_rt_sigreturn +#define MIPS_INST_LI_V0_N32_RT_SIGRETURN 0x24020000 + MIPS_NR_N32_rt_sigreturn +#define MIPS_INST_SYSCALL 0x0000000c + +struct tramp_frame mips_linux_o32_sigframe = { + 4, + { MIPS_INST_LI_V0_SIGRETURN, MIPS_INST_SYSCALL, TRAMP_SENTINEL_INSN }, + mips_linux_o32_sigframe_init +}; + +struct tramp_frame mips_linux_o32_rt_sigframe = { + 4, + { MIPS_INST_LI_V0_RT_SIGRETURN, MIPS_INST_SYSCALL, TRAMP_SENTINEL_INSN }, + mips_linux_o32_sigframe_init +}; + +struct tramp_frame mips_linux_n32_rt_sigframe = { + 4, + { MIPS_INST_LI_V0_N32_RT_SIGRETURN, MIPS_INST_SYSCALL, TRAMP_SENTINEL_INSN }, + mips_linux_n32n64_sigframe_init +}; + +struct tramp_frame mips_linux_n64_rt_sigframe = { + 4, + { MIPS_INST_LI_V0_N64_RT_SIGRETURN, MIPS_INST_SYSCALL, TRAMP_SENTINEL_INSN }, + mips_linux_n32n64_sigframe_init +}; + +/* *INDENT-OFF* */ +/* The unwinder for o32 signal frames. The legacy structures look + like this: + + struct sigframe { + u32 sf_ass[4]; [argument save space for o32] + u32 sf_code[2]; [signal trampoline] + struct sigcontext sf_sc; + sigset_t sf_mask; + }; + + struct sigcontext { + unsigned int sc_regmask; [Unused] + unsigned int sc_status; + unsigned long long sc_pc; + unsigned long long sc_regs[32]; + unsigned long long sc_fpregs[32]; + unsigned int sc_ownedfp; + unsigned int sc_fpc_csr; + unsigned int sc_fpc_eir; [Unused] + unsigned int sc_used_math; + unsigned int sc_ssflags; [Unused] + [Alignment hole of four bytes] + unsigned long long sc_mdhi; + unsigned long long sc_mdlo; + + unsigned int sc_cause; [Unused] + unsigned int sc_badvaddr; [Unused] + + unsigned long sc_sigset[4]; [kernel's sigset_t] + }; + + The RT signal frames look like this: + + struct rt_sigframe { + u32 rs_ass[4]; [argument save space for o32] + u32 rs_code[2] [signal trampoline] + struct siginfo rs_info; + struct ucontext rs_uc; + }; + + struct ucontext { + unsigned long uc_flags; + struct ucontext *uc_link; + stack_t uc_stack; + [Alignment hole of four bytes] + struct sigcontext uc_mcontext; + sigset_t uc_sigmask; + }; */ +/* *INDENT-ON* */ + +#define SIGFRAME_CODE_OFFSET (4 * 4) +#define SIGFRAME_SIGCONTEXT_OFFSET (6 * 4) + +#define RTSIGFRAME_SIGINFO_SIZE 128 +#define STACK_T_SIZE (3 * 4) +#define UCONTEXT_SIGCONTEXT_OFFSET (2 * 4 + STACK_T_SIZE + 4) +#define RTSIGFRAME_SIGCONTEXT_OFFSET (SIGFRAME_SIGCONTEXT_OFFSET \ + + RTSIGFRAME_SIGINFO_SIZE \ + + UCONTEXT_SIGCONTEXT_OFFSET) + +#define SIGCONTEXT_PC (1 * 8) +#define SIGCONTEXT_REGS (2 * 8) +#define SIGCONTEXT_FPREGS (34 * 8) +#define SIGCONTEXT_FPCSR (66 * 8 + 4) +#define SIGCONTEXT_HI (69 * 8) +#define SIGCONTEXT_LO (70 * 8) +#define SIGCONTEXT_CAUSE (71 * 8 + 0) +#define SIGCONTEXT_BADVADDR (71 * 8 + 4) + +#define SIGCONTEXT_REG_SIZE 8 + +static void +mips_linux_o32_sigframe_init (const struct tramp_frame *self, + struct frame_info *next_frame, + struct trad_frame_cache *this_cache, + CORE_ADDR func) +{ + int ireg, reg_position; + CORE_ADDR sigcontext_base = func - SIGFRAME_CODE_OFFSET; + const struct mips_regnum *regs = mips_regnum (current_gdbarch); + + if (self == &mips_linux_o32_sigframe) + sigcontext_base += SIGFRAME_SIGCONTEXT_OFFSET; + else + sigcontext_base += RTSIGFRAME_SIGCONTEXT_OFFSET; + + /* I'm not proud of this hack. Eventually we will have the infrastructure + to indicate the size of saved registers on a per-frame basis, but + right now we don't; the kernel saves eight bytes but we only want + four. */ + if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG) + sigcontext_base += 4; + +#if 0 + trad_frame_set_reg_addr (this_cache, ORIG_ZERO_REGNUM + NUM_REGS, + sigcontext_base + SIGCONTEXT_REGS); +#endif + + for (ireg = 1; ireg < 32; ireg++) + trad_frame_set_reg_addr (this_cache, ireg + ZERO_REGNUM + NUM_REGS, + sigcontext_base + SIGCONTEXT_REGS + + ireg * SIGCONTEXT_REG_SIZE); + + for (ireg = 0; ireg < 32; ireg++) + trad_frame_set_reg_addr (this_cache, ireg + regs->fp0 + NUM_REGS, + sigcontext_base + SIGCONTEXT_FPREGS + + ireg * SIGCONTEXT_REG_SIZE); + + trad_frame_set_reg_addr (this_cache, regs->pc + NUM_REGS, + sigcontext_base + SIGCONTEXT_PC); + + trad_frame_set_reg_addr (this_cache, regs->fp_control_status + NUM_REGS, + sigcontext_base + SIGCONTEXT_FPCSR); + trad_frame_set_reg_addr (this_cache, regs->hi + NUM_REGS, + sigcontext_base + SIGCONTEXT_HI); + trad_frame_set_reg_addr (this_cache, regs->lo + NUM_REGS, + sigcontext_base + SIGCONTEXT_LO); + trad_frame_set_reg_addr (this_cache, regs->cause + NUM_REGS, + sigcontext_base + SIGCONTEXT_CAUSE); + trad_frame_set_reg_addr (this_cache, regs->badvaddr + NUM_REGS, + sigcontext_base + SIGCONTEXT_BADVADDR); + + /* Choice of the bottom of the sigframe is somewhat arbitrary. */ + trad_frame_set_id (this_cache, + frame_id_build (func - SIGFRAME_CODE_OFFSET, func)); +} + +/* *INDENT-OFF* */ +/* For N32/N64 things look different. There is no non-rt signal frame. + + struct rt_sigframe_n32 { + u32 rs_ass[4]; [ argument save space for o32 ] + u32 rs_code[2]; [ signal trampoline ] + struct siginfo rs_info; + struct ucontextn32 rs_uc; + }; + + struct ucontextn32 { + u32 uc_flags; + s32 uc_link; + stack32_t uc_stack; + struct sigcontext uc_mcontext; + sigset_t uc_sigmask; [ mask last for extensibility ] + }; + + struct rt_sigframe_n32 { + u32 rs_ass[4]; [ argument save space for o32 ] + u32 rs_code[2]; [ signal trampoline ] + struct siginfo rs_info; + struct ucontext rs_uc; + }; + + struct ucontext { + unsigned long uc_flags; + struct ucontext *uc_link; + stack_t uc_stack; + struct sigcontext uc_mcontext; + sigset_t uc_sigmask; [ mask last for extensibility ] + }; + + And the sigcontext is different (this is for both n32 and n64): + + struct sigcontext { + unsigned long long sc_regs[32]; + unsigned long long sc_fpregs[32]; + unsigned long long sc_mdhi; + unsigned long long sc_mdlo; + unsigned long long sc_pc; + unsigned int sc_status; + unsigned int sc_fpc_csr; + unsigned int sc_fpc_eir; + unsigned int sc_used_math; + unsigned int sc_cause; + unsigned int sc_badvaddr; + }; */ +/* *INDENT-ON* */ + +#define N32_STACK_T_SIZE STACK_T_SIZE +#define N64_STACK_T_SIZE (2 * 8 + 4) +#define N32_UCONTEXT_SIGCONTEXT_OFFSET (2 * 4 + N32_STACK_T_SIZE + 4) +#define N64_UCONTEXT_SIGCONTEXT_OFFSET (2 * 8 + N64_STACK_T_SIZE + 4) +#define N32_SIGFRAME_SIGCONTEXT_OFFSET (SIGFRAME_SIGCONTEXT_OFFSET \ + + RTSIGFRAME_SIGINFO_SIZE \ + + N32_UCONTEXT_SIGCONTEXT_OFFSET) +#define N64_SIGFRAME_SIGCONTEXT_OFFSET (SIGFRAME_SIGCONTEXT_OFFSET \ + + RTSIGFRAME_SIGINFO_SIZE \ + + N64_UCONTEXT_SIGCONTEXT_OFFSET) + +#define N64_SIGCONTEXT_REGS (0 * 8) +#define N64_SIGCONTEXT_FPREGS (32 * 8) +#define N64_SIGCONTEXT_HI (64 * 8) +#define N64_SIGCONTEXT_LO (65 * 8) +#define N64_SIGCONTEXT_PC (66 * 8) +#define N64_SIGCONTEXT_FPCSR (67 * 8 + 1 * 4) +#define N64_SIGCONTEXT_FIR (67 * 8 + 2 * 4) +#define N64_SIGCONTEXT_CAUSE (67 * 8 + 4 * 4) +#define N64_SIGCONTEXT_BADVADDR (67 * 8 + 5 * 4) + +#define N64_SIGCONTEXT_REG_SIZE 8 + +static void +mips_linux_n32n64_sigframe_init (const struct tramp_frame *self, + struct frame_info *next_frame, + struct trad_frame_cache *this_cache, + CORE_ADDR func) +{ + int ireg, reg_position; + CORE_ADDR sigcontext_base = func - SIGFRAME_CODE_OFFSET; + const struct mips_regnum *regs = mips_regnum (current_gdbarch); + + if (self == &mips_linux_n32_rt_sigframe) + sigcontext_base += N32_SIGFRAME_SIGCONTEXT_OFFSET; + else + sigcontext_base += N64_SIGFRAME_SIGCONTEXT_OFFSET; + +#if 0 + trad_frame_set_reg_addr (this_cache, ORIG_ZERO_REGNUM + NUM_REGS, + sigcontext_base + N64_SIGCONTEXT_REGS); +#endif + + for (ireg = 1; ireg < 32; ireg++) + trad_frame_set_reg_addr (this_cache, ireg + ZERO_REGNUM + NUM_REGS, + sigcontext_base + N64_SIGCONTEXT_REGS + + ireg * N64_SIGCONTEXT_REG_SIZE); + + for (ireg = 0; ireg < 32; ireg++) + trad_frame_set_reg_addr (this_cache, ireg + regs->fp0 + NUM_REGS, + sigcontext_base + N64_SIGCONTEXT_FPREGS + + ireg * N64_SIGCONTEXT_REG_SIZE); + + trad_frame_set_reg_addr (this_cache, regs->pc + NUM_REGS, + sigcontext_base + N64_SIGCONTEXT_PC); + + trad_frame_set_reg_addr (this_cache, regs->fp_control_status + NUM_REGS, + sigcontext_base + N64_SIGCONTEXT_FPCSR); + trad_frame_set_reg_addr (this_cache, regs->hi + NUM_REGS, + sigcontext_base + N64_SIGCONTEXT_HI); + trad_frame_set_reg_addr (this_cache, regs->lo + NUM_REGS, + sigcontext_base + N64_SIGCONTEXT_LO); + trad_frame_set_reg_addr (this_cache, regs->cause + NUM_REGS, + sigcontext_base + N64_SIGCONTEXT_CAUSE); + trad_frame_set_reg_addr (this_cache, regs->badvaddr + NUM_REGS, + sigcontext_base + N64_SIGCONTEXT_BADVADDR); + + /* Choice of the bottom of the sigframe is somewhat arbitrary. */ + trad_frame_set_id (this_cache, + frame_id_build (func - SIGFRAME_CODE_OFFSET, func)); +} + +/* Initialize one of the GNU/Linux OS ABIs. */ + static void mips_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) { @@ -811,6 +1119,8 @@ mips_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) set_solib_svr4_fetch_link_map_offsets (gdbarch, mips_linux_svr4_fetch_link_map_offsets); set_mips_linux_register_addr (gdbarch, mips_linux_register_addr); + tramp_frame_append (gdbarch, &mips_linux_o32_sigframe); + tramp_frame_append (gdbarch, &mips_linux_o32_rt_sigframe); break; case MIPS_ABI_N32: set_gdbarch_get_longjmp_target (gdbarch, @@ -818,6 +1128,7 @@ mips_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) set_solib_svr4_fetch_link_map_offsets (gdbarch, mips_linux_svr4_fetch_link_map_offsets); set_mips_linux_register_addr (gdbarch, mips64_linux_register_addr); + tramp_frame_append (gdbarch, &mips_linux_n32_rt_sigframe); break; case MIPS_ABI_N64: set_gdbarch_get_longjmp_target (gdbarch, @@ -825,6 +1136,7 @@ mips_linux_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch) set_solib_svr4_fetch_link_map_offsets (gdbarch, mips64_linux_svr4_fetch_link_map_offsets); set_mips_linux_register_addr (gdbarch, mips64_linux_register_addr); + tramp_frame_append (gdbarch, &mips_linux_n64_rt_sigframe); break; default: internal_error (__FILE__, __LINE__, "can't handle ABI"); diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index 563a7d89552..cf1eddc7663 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -5741,9 +5741,7 @@ mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* Unwind the frame. */ set_gdbarch_unwind_pc (gdbarch, mips_unwind_pc); - frame_unwind_append_sniffer (gdbarch, mips_mdebug_frame_sniffer); set_gdbarch_unwind_dummy_id (gdbarch, mips_unwind_dummy_id); - frame_base_append_sniffer (gdbarch, mips_mdebug_frame_base_sniffer); /* Map debug register numbers onto internal register numbers. */ set_gdbarch_stab_reg_to_regnum (gdbarch, mips_stab_reg_to_regnum); @@ -5808,6 +5806,10 @@ mips_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) /* Hook in OS ABI-specific overrides, if they have been registered. */ gdbarch_init_osabi (info, gdbarch); + /* Unwind the frame. */ + frame_unwind_append_sniffer (gdbarch, mips_mdebug_frame_sniffer); + frame_base_append_sniffer (gdbarch, mips_mdebug_frame_base_sniffer); + return gdbarch; } diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c index ba2733ee717..c2223d29fc3 100644 --- a/gdb/ppc-linux-tdep.c +++ b/gdb/ppc-linux-tdep.c @@ -1076,6 +1076,15 @@ ppc_linux_init_abi (struct gdbarch_info info, if (tdep->wordsize == 4) { + /* NOTE: jimb/2004-03-26: The System V ABI PowerPC Processor + Supplement says that long doubles are sixteen bytes long. + However, as one of the known warts of its ABI, PPC GNU/Linux + uses eight-byte long doubles. GCC only recently got 128-bit + long double support on PPC, so it may be changing soon. The + Linux Standards Base says that programs that use 'long + double' on PPC GNU/Linux are non-conformant. */ + set_gdbarch_long_double_bit (gdbarch, 8 * TARGET_CHAR_BIT); + /* Until November 2001, gcc did not comply with the 32 bit SysV R4 ABI requirement that structures less than or equal to 8 bytes should be returned in registers. Instead GCC was using diff --git a/gdb/remote-rdp.c b/gdb/remote-rdp.c index 2db0a910d83..eab68eaf9e4 100644 --- a/gdb/remote-rdp.c +++ b/gdb/remote-rdp.c @@ -630,7 +630,7 @@ remote_rdp_fetch_register (int regno) } else { - char buf[ARM_MAX_REGISTER_RAW_SIZE]; + char buf[MAX_REGISTER_SIZE]; if (regno < 15) rdp_fetch_one_register (1 << regno, buf); else if (regno == ARM_PC_REGNUM) @@ -660,7 +660,7 @@ remote_rdp_store_register (int regno) } else { - char tmp[ARM_MAX_REGISTER_RAW_SIZE]; + char tmp[MAX_REGISTER_SIZE]; deprecated_read_register_gen (regno, tmp); if (regno < 15) rdp_store_one_register (1 << regno, tmp); diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index 6c85be82dcc..2b2d4b44022 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-03-24 Daniel Jacobowitz <drow@mvista.com> + + * gdb.base/gdb1250.exp: Use runto {allow-pending}. + * lib/gdb.exp (runto, gdb_breakpoint): Support {allow-pending}. + 2004-03-22 Andrew Cagney <cagney@redhat.com> * gdb.base/watchpoint.exp (test_stepping): Delete bogus XFAILs diff --git a/gdb/testsuite/gdb.base/gdb1250.exp b/gdb/testsuite/gdb.base/gdb1250.exp index 60a6f5971c3..4ffdf2baffc 100644 --- a/gdb/testsuite/gdb.base/gdb1250.exp +++ b/gdb/testsuite/gdb.base/gdb1250.exp @@ -42,7 +42,7 @@ gdb_start gdb_reinitialize_dir $srcdir/$subdir gdb_load ${binfile} -if ![runto abort] then { +if ![runto abort {allow-pending}] then { perror "couldn't run to breakpoint" continue } diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp index 72d9143ab21..f49cbbf9855 100644 --- a/gdb/testsuite/lib/gdb.exp +++ b/gdb/testsuite/lib/gdb.exp @@ -265,18 +265,32 @@ proc gdb_run_cmd {args} { } } -proc gdb_breakpoint { function } { +# Set a breakpoint at FUNCTION. If there is an additional argument it is +# a list of options; the only currently supported option is allow-pending. + +proc gdb_breakpoint { function args } { global gdb_prompt global decimal + set pending_response n + if {[lsearch -exact [lindex $args 0] allow-pending] != -1} { + set pending_response y + } + send_gdb "break $function\n" # The first two regexps are what we get with -g, the third is without -g. gdb_expect 30 { -re "Breakpoint \[0-9\]* at .*: file .*, line $decimal.\r\n$gdb_prompt $" {} -re "Breakpoint \[0-9\]*: file .*, line $decimal.\r\n$gdb_prompt $" {} -re "Breakpoint \[0-9\]* at .*$gdb_prompt $" {} + -re "Breakpoint \[0-9\]* \\(.*\\) pending.*$gdb_prompt $" { + if {$pending_response == "n"} { + fail "setting breakpoint at $function" + return 0 + } + } -re "Make breakpoint pending.*y or \\\[n\\\]. $" { - send_gdb "n\n" + send_gdb "$pending_response\n" exp_continue } -re "$gdb_prompt $" { fail "setting breakpoint at $function" ; return 0 } @@ -289,15 +303,16 @@ proc gdb_breakpoint { function } { # Since this is the only breakpoint that will be set, if it stops # at a breakpoint, we will assume it is the one we want. We can't # just compare to "function" because it might be a fully qualified, -# single quoted C++ function specifier. +# single quoted C++ function specifier. If there's an additional argument, +# pass it to gdb_breakpoint. -proc runto { function } { +proc runto { function args } { global gdb_prompt global decimal delete_breakpoints - if ![gdb_breakpoint $function] { + if ![gdb_breakpoint $function [lindex $args 0]] { return 0; } diff --git a/gdb/trad-frame.h b/gdb/trad-frame.h index 194f39abdfb..51f3a0ea9e3 100644 --- a/gdb/trad-frame.h +++ b/gdb/trad-frame.h @@ -42,6 +42,8 @@ void trad_frame_get_id (struct trad_frame_cache *this_trad_cache, void trad_frame_set_reg_unknown (struct trad_frame_cache *this_trad_cache, int regnum, CORE_ADDR addr); +void trad_frame_set_reg_addr (struct trad_frame_cache *this_trad_cache, + int regnum, CORE_ADDR addr); void trad_frame_get_register (struct trad_frame_cache *this_trad_cache, struct frame_info *next_frame, int regnum, int *optimizedp, diff --git a/gdb/tramp-frame.c b/gdb/tramp-frame.c index 7a8057e85e1..ee3635f743b 100644 --- a/gdb/tramp-frame.c +++ b/gdb/tramp-frame.c @@ -28,6 +28,7 @@ #include "target.h" #include "trad-frame.h" #include "frame-base.h" +#include "gdb_assert.h" struct frame_data { @@ -89,15 +90,15 @@ tramp_frame_start (CORE_ADDR pc, const struct tramp_frame *tramp) int ti; /* Search through the trampoline for one that matches the instruction sequence around PC. */ - for (ti = 0; tramp->insn[ti] != 0; ti++) + for (ti = 0; tramp->insn[ti] != TRAMP_SENTINEL_INSN; ti++) { CORE_ADDR func = pc - tramp->insn_size * ti; int i; for (i = 0; 1; i++) { - bfd_byte buf[sizeof (LONGEST)]; - CORE_ADDR insn; - if (tramp->insn[i] == 0) + bfd_byte buf[sizeof (tramp->insn[0])]; + ULONGEST insn; + if (tramp->insn[i] == TRAMP_SENTINEL_INSN) return func; if (target_read_memory (func + i * tramp->insn_size, buf, tramp->insn_size) != 0) @@ -148,6 +149,16 @@ tramp_frame_append (struct gdbarch *gdbarch, { struct frame_data *data; struct frame_unwind *unwinder; + int i; + + /* Check that the instruction sequence contains a sentinel. */ + for (i = 0; i < ARRAY_SIZE (tramp_frame->insn); i++) + { + if (tramp_frame->insn[i] == TRAMP_SENTINEL_INSN) + break; + } + gdb_assert (i < ARRAY_SIZE (tramp_frame->insn)); + gdb_assert (tramp_frame->insn_size <= sizeof (tramp_frame->insn[0])); data = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct frame_data); unwinder = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct frame_unwind); diff --git a/gdb/tramp-frame.h b/gdb/tramp-frame.h index 44e266eaab6..54f29bbca54 100644 --- a/gdb/tramp-frame.h +++ b/gdb/tramp-frame.h @@ -39,6 +39,10 @@ struct trad_frame_cache; /* A trampoline descriptor. */ +/* Magic instruction that to mark the end of the signal trampoline + instruction sequence. */ +#define TRAMP_SENTINEL_INSN ((LONGEST) -1) + struct tramp_frame { /* The trampoline's entire instruction sequence. Search for this in @@ -47,7 +51,8 @@ struct tramp_frame one INSN_SIZE instruction. It is also assumed that TRAMP[0] contains the first instruction of the trampoline and hence the address of the instruction matching TRAMP[0] is the trampoline's - "func" address. */ + "func" address. The instruction sequence shall be terminated by + TRAMP_SENTINEL_INSN. */ int insn_size; ULONGEST insn[8]; /* Initialize a trad-frame cache corresponding to the tramp-frame. diff --git a/gdb/version.in b/gdb/version.in index 81a2d2c5111..9b11d14f42b 100644 --- a/gdb/version.in +++ b/gdb/version.in @@ -1 +1 @@ -2004-03-23-cvs +2004-03-26-cvs diff --git a/include/ChangeLog b/include/ChangeLog index 7f600049a1b..16886b65a61 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,7 @@ +2004-03-25 Stan Shebs <shebs@apple.com> + + * mpw/: Remove subdirectory and everything in it. + 2004-03-23 Alan Modra <amodra@bigpond.net.au> PR 51. diff --git a/include/mpw/ChangeLog b/include/mpw/ChangeLog deleted file mode 100644 index 8dbad87eab4..00000000000 --- a/include/mpw/ChangeLog +++ /dev/null @@ -1,61 +0,0 @@ -Tue Feb 27 12:23:04 1996 Raymond Jou <rjou@mexican.cygnus.com> - - * mpw.h (HAVE_VPRINTF): Add and define to have the value 1. - -Fri Dec 29 14:40:46 1995 Stan Shebs <shebs@andros.cygnus.com> - - * mpw.h (HAVE_STDLIB_H, etc): Define to have the value 1. - (HAVE_FCNTL_H): Define. - -Mon Dec 11 15:39:06 1995 Stan Shebs <shebs@andros.cygnus.com> - - * mpw.h (open, access): Define as mpw_open and mpw_access. - -Thu Nov 9 15:38:37 1995 Stan Shebs <shebs@andros.cygnus.com> - - * mpw.h: Include unix.h if USE_MW_HEADERS, otherwise include - various original MPW include files (ioctl.h, etc). - (EIO): Define if not defined. - * sys/ioctl.h: Remove, not needed. - -Wed Oct 25 12:30:44 1995 Stan Shebs <shebs@andros.cygnus.com> - - * mpw.h: Don't include errno.h or ioctl.h. - (ENOENT, EACCES, ENOSYS): Define if not defined. - (fdopen): Declare if __STDC__. - (R_OK, W_OK, X_OK): Define if not defined. - -Tue Sep 26 14:57:21 1995 Stan Shebs <shebs@andros.cygnus.com> - - * mpw.h: New file, universally useful MPW host definitions. - Many of these used to live in bfd/hosts/mpw.h. - * grp.h: Remove RCS comment. - * sys/ioctl.h: Add a comment line. - -Wed Dec 14 13:12:14 1994 Stan Shebs <shebs@andros.cygnus.com> - - * spin.h: New file, cursor spinning for progress. - -Thu Jun 30 15:32:07 1994 Stan Shebs (shebs@andros.cygnus.com) - - * fcntl.h (open): Allow optional third arg. - -Thu Apr 14 12:54:51 1994 Stan Shebs (shebs@andros.cygnus.com) - - * dir.h, dirent.h, fcntl.h, grp.h, pwd.h, stat.h: New files. - * sys/ioctl.h: New file. - -Mon Feb 21 09:44:45 1994 Stan Shebs (shebs@andros.cygnus.com) - - * sys/stat.h (struct stat): New field st_rsize. - (S_IFMT, etc): Use different bit positions. - (fstat): Add parameter names to prototype. - -Mon Jan 31 19:30:16 1994 Stan Shebs (shebs@andros.cygnus.com) - - * README: New file. - * utime.h, varargs.h: New files, simulated Posix. - * sys/{file,param,resource,stat,time,types}.h: New files, more - simulated Posix. - - diff --git a/include/mpw/README b/include/mpw/README deleted file mode 100644 index 10e92de79f6..00000000000 --- a/include/mpw/README +++ /dev/null @@ -1 +0,0 @@ -This is a collection of include files that help imitate Posix in MPW. diff --git a/include/mpw/dir.h b/include/mpw/dir.h deleted file mode 100644 index e6ccd2d5922..00000000000 --- a/include/mpw/dir.h +++ /dev/null @@ -1,23 +0,0 @@ -/* The <dir.h> header gives the layout of a directory. */ - -#pragma once - -#ifndef _DIR_H -#define _DIR_H - -#ifndef _TYPES_H /* not quite right */ -#include <sys/types.h> -#endif - -#define DIRBLKSIZ 512 /* size of directory block */ - -#ifndef DIRSIZ -#define DIRSIZ 14 -#endif - -struct direct { - ino_t d_ino; - char d_name[DIRSIZ]; -}; - -#endif /* _DIR_H */ diff --git a/include/mpw/dirent.h b/include/mpw/dirent.h deleted file mode 100644 index 38000b2c5f3..00000000000 --- a/include/mpw/dirent.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef __dirent_h -#define __dirent_h - -#include "sys/dir.h" - -struct dirent { - long d_ino; /* inode number of entry */ - off_t d_off; /* offset of disk directory entry */ - unsigned short d_reclen; /* length of this record */ - char d_name[1]; /* name of file */ -}; - -/* -#define DIRENTBASESIZE \ - (((struct dirent *) 0)->d_name - (char *) 0) -#define DIRENTSIZE(namelen) \ - ((DIRENTBASESIZE + (namelen) + NBPW) & ~(NBPW - 1)) -*/ - -/* from Mips posix/dirent.h */ - -/* -#undef rewinddir -*/ - -extern DIR *opendir(); -extern struct dirent *readdir(); -extern void rewinddir(); -extern int closedir(); - -#endif /* ! __dirent_h */ diff --git a/include/mpw/fcntl.h b/include/mpw/fcntl.h deleted file mode 100644 index 30999b4b17d..00000000000 --- a/include/mpw/fcntl.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - * FCntl.h -- faccess(), fcntl(), and open() mode flags - * - * Portions copyright American Telephone & Telegraph - * Used with permission, Apple Computer Inc. (1985,1988,1990,1992) - * All rights reserved. - */ - -#ifndef __FCNTL__ -#define __FCNTL__ - -#ifndef __TYPES__ -#include <Types.h> -#endif - -/* - * For use by lseek(): - */ - -#ifndef __STDIO__ /* these defns exactly paralled in StdIO.h for fseek() */ -#define SEEK_CUR 1 -#define SEEK_END 2 -#define SEEK_SET 0 -#endif - -/* - * faccess() commands; for general use - */ - /* 'd' => "directory" ops */ -#define F_DELETE (('d'<<8)|0x01) -#define F_RENAME (('d'<<8)|0x02) - -/* - * more faccess() commands; for use only by MPW tools - */ - -#define F_OPEN (('d'<<8)|0x00) /* reserved for operating system use */ - /* 'e' => "editor" ops */ -#define F_GTABINFO (('e'<<8)|0x00) /* get tab offset for file */ -#define F_STABINFO (('e'<<8)|0x01) /* set " " " " */ -#define F_GFONTINFO (('e'<<8)|0x02) /* get font number and size for file */ -#define F_SFONTINFO (('e'<<8)|0x03) /* set " " " " " " */ -#define F_GPRINTREC (('e'<<8)|0x04) /* get print record for file */ -#define F_SPRINTREC (('e'<<8)|0x05) /* set " " " " */ -#define F_GSELINFO (('e'<<8)|0x06) /* get selection information for file */ -#define F_SSELINFO (('e'<<8)|0x07) /* set " " " " */ -#define F_GWININFO (('e'<<8)|0x08) /* get current window position */ -#define F_SWININFO (('e'<<8)|0x09) /* set " " " */ -#define F_GSCROLLINFO (('e'<<8)|0x0A) /* get scroll information */ -#define F_SSCROLLINFO (('e'<<8)|0x0B) /* set " " */ -#define F_GMARKER (('e'<<8)|0x0D) /* Get Marker */ -#define F_SMARKER (('e'<<8)|0x0C) /* Set " */ -#define F_GSAVEONCLOSE (('e'<<8)|0x0F) /* Get Save on close */ -#define F_SSAVEONCLOSE (('e'<<8)|0x0E) /* Set " " " */ - -/* - * argument structures used by various faccess() commands - */ - -struct MarkElement { - int start; /* start position of mark */ - int end; /* end position */ - unsigned char charCount; /* number of chars in mark name */ - char name[64]; /* mark name */ -} ; /* note: marker names may be up to 64 characters long */ - -#ifndef __cplusplus -typedef struct MarkElement MarkElement; -#endif - -struct SelectionRecord { - long startingPos; - long endingPos; - long displayTop; -}; - -#ifndef __cplusplus -typedef struct SelectionRecord SelectionRecord; -#endif - - -/* - * Mode values accessible to open() - */ -#define O_RDONLY 0 /* Bits 0 and 1 are used internally */ -#define O_WRONLY 1 /* Values 0..2 are historical */ -#define O_RDWR 2 /* NOTE: it goes 0, 1, 2, *!* 8, 16, 32, ... */ -#define O_APPEND (1<< 3) /* append (writes guaranteed at the end) */ -#define O_RSRC (1<< 4) /* Open the resource fork */ -#define O_ALIAS (1<< 5) /* Open alias file */ -#define O_CREAT (1<< 8) /* Open with file create */ -#define O_TRUNC (1<< 9) /* Open with truncation */ -#define O_EXCL (1<<10) /* w/ O_CREAT: Exclusive "create-only" */ -#define O_BINARY (1<<11) /* Open as a binary stream */ -#define O_NRESOLVE (1<<14) /* Don't resolve any aliases */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * function prototypes - */ -int close(int); -int creat(const char*); -int dup(int filedes); /* OBSOLETE: fcntl(filedes, F_DUPFD, 0) is preferred */ -int faccess(char*, unsigned int, long*); -int fcntl(int, unsigned int, int); -long lseek(int, long, int); -int open(const char*, int, ...); -int read(int, char*, unsigned); -int unlink(char*); -int write(int, const char*, unsigned); - -#ifdef __cplusplus -} -#endif - -/* - * fcntl() commands - */ -#define F_DUPFD 0 /* Duplicate files (file descriptor) */ - -#endif __FCNTL__ diff --git a/include/mpw/grp.h b/include/mpw/grp.h deleted file mode 100644 index faf2c6a6be9..00000000000 --- a/include/mpw/grp.h +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -#include "sys/types.h" - -struct group { - char *gr_name; - gid_t gr_gid; - char *gr_passwd; - char **gr_mem; -}; diff --git a/include/mpw/mpw.h b/include/mpw/mpw.h deleted file mode 100644 index 58702e725ff..00000000000 --- a/include/mpw/mpw.h +++ /dev/null @@ -1,130 +0,0 @@ -/* Mac MPW host-specific definitions. */ - -#ifndef __INCLUDE_MPW_H -#define __INCLUDE_MPW_H - -#ifndef MPW -#define MPW -#endif - -/* MPW C is basically ANSI, but doesn't actually enable __STDC__, - nor does it allow __STDC__ to be #defined. */ - -#ifndef ALMOST_STDC -#define ALMOST_STDC -#endif - -#include <stdio.h> -#include <ctype.h> -#include <errno.h> - -#define HAVE_TIME_T_IN_TIME_H 1 - -#define HAVE_STDLIB_H 1 - -#define HAVE_ERRNO_H 1 - -#define HAVE_STDDEF_H 1 - -#define HAVE_STRING_H 1 - -#define HAVE_STDARG_H 1 - -#define HAVE_VPRINTF 1 - -#ifdef USE_MW_HEADERS - -#include <unix.h> - -#else - -#include <fcntl.h> -#include <ioctl.h> -#include <sys/stat.h> - -#define HAVE_FCNTL_H 1 - -#ifndef O_ACCMODE -#define O_ACCMODE (O_RDONLY | O_WRONLY | O_RDWR) -#endif - -#ifndef fileno -#define fileno(fp) ((fp)->_file) -#endif - -/* stdio.h does not define this if __STDC__, so define here. */ - -#ifdef __STDC__ -FILE *fdopen(int fildes, const char *mode); -#endif - -#endif /* USE_MW_HEADERS */ - -/* Add ersatz definitions, for systems that lack them. */ - -#ifndef EIO -#define EIO 96 -#endif -#ifndef ENOENT -#define ENOENT 97 -#endif -#ifndef EACCES -#define EACCES 98 -#endif -#ifndef ENOSYS -#define ENOSYS 99 -#endif - -#ifndef R_OK -#define R_OK 4 -#define W_OK 2 -#define X_OK 1 -#endif - -/* Binary files have different characteristics; for instance, no cr/nl - translation. */ - -#define USE_BINARY_FOPEN - -#include <spin.h> - -#ifdef MPW_C -#undef __PTR_TO_INT -#define __PTR_TO_INT(P) ((int)(P)) -#undef __INT_TO_PTR -#define __INT_TO_PTR(P) ((char *)(P)) -#endif /* MPW_C */ - -#define NO_FCNTL - -int fstat (); - -FILE *mpw_fopen (); -int mpw_fseek (); -int mpw_fread (); -int mpw_fwrite (); -int mpw_access (); -int mpw_open (); -int mpw_creat (); -void mpw_abort (void); - -/* Map these standard functions to improved versions in libiberty. */ - -#define fopen mpw_fopen -#define fseek mpw_fseek -#define fread mpw_fread -#define fwrite mpw_fwrite -#define open mpw_open -#define access mpw_access -#define creat mpw_creat -#define abort mpw_abort - -#define POSIX_UTIME - -#define LOSING_TOTALLY - -/* Define this so that files will be closed before being unlinked. */ - -#define CLOSE_BEFORE_UNLINK - -#endif /* __INCLUDE_MPW_H */ diff --git a/include/mpw/pwd.h b/include/mpw/pwd.h deleted file mode 100644 index 2d4fb70401a..00000000000 --- a/include/mpw/pwd.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef __pwd_h -#define __pwd_h - -#include <sys/types.h> - -struct passwd { - char *pw_name; - uid_t pw_uid; - gid_t pw_gid; - char *pw_dir; - char *pw_shell; - char *pw_passwd; -}; - -#endif /* ! __pwd_h */ diff --git a/include/mpw/spin.h b/include/mpw/spin.h deleted file mode 100644 index 674b00ac60b..00000000000 --- a/include/mpw/spin.h +++ /dev/null @@ -1,64 +0,0 @@ -/* Progress macros that use SpinCursor in MPW. - Copyright 1994 Free Software Foundation, Inc. - -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 2 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, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -#ifndef _SPIN_H -#define _SPIN_H - -/* For MPW, progress macros just need to "spin the cursor" frequently, - preferably several times per second on a 68K Mac. */ - -/* In order to determine if we're meeting the goal, define this macro - and information about frequency of spinning will be collected and - displayed. */ - -#define SPIN_MEASUREMENT - -#include <CursorCtl.h> - -/* Programs use this macro to indicate the start of a lengthy - activity. STR identifies the particular activity, while N - indicates the expected duration, in unspecified units. If N is - zero, then the expected time to completion is unknown. */ - -#undef START_PROGRESS -#define START_PROGRESS(STR,N) mpw_start_progress (STR, N, __FILE__, __LINE__); - -/* Programs use this macro to indicate that progress has been made on a - lengthy activity. */ - -#undef PROGRESS -#ifdef SPIN_MEASUREMENT -#define PROGRESS(X) mpw_progress_measured (X, __FILE__, __LINE__); -#else -#define PROGRESS(X) mpw_progress (X); -#endif - -/* Programs use this macro to indicate the end of a lengthy activity. - STR must match a STR passed to START_PROGRESS previously. */ - -#undef END_PROGRESS -#define END_PROGRESS(STR) mpw_end_progress (STR, __FILE__, __LINE__); - -extern void mpw_start_progress (char *, int, char *, int); - -extern void mpw_progress (int); - -extern void mpw_progress_measured (int, char *, int); - -extern void mpw_end_progress (char *, char *, int); - -#endif /* _SPIN_H */ diff --git a/include/mpw/stat.h b/include/mpw/stat.h deleted file mode 100644 index 057b8d53113..00000000000 --- a/include/mpw/stat.h +++ /dev/null @@ -1,75 +0,0 @@ -/* The <sys/stat.h> header defines a struct that is used in the stat() and - * fstat functions. The information in this struct comes from the i-node of - * some file. These calls are the only approved way to inspect i-nodes. - */ - -#ifndef _STAT_H -#define _STAT_H - -#ifndef _TYPES_H /* not quite right */ -#include <sys/types.h> -#endif - -struct stat { - dev_t st_dev; /* major/minor device number */ - ino_t st_ino; /* i-node number */ - mode_t st_mode; /* file mode, protection bits, etc. */ - short int st_nlink; /* # links; TEMPORARY HACK: should be nlink_t*/ - uid_t st_uid; /* uid of the file's owner */ - short int st_gid; /* gid; TEMPORARY HACK: should be gid_t */ - dev_t st_rdev; - off_t st_size; /* file size */ - time_t st_atime; /* time of last access */ - time_t st_mtime; /* time of last data modification */ - time_t st_ctime; /* time of last file status change */ -}; - -/* Traditional mask definitions for st_mode. */ -#define S_IFMT 0170000 /* type of file */ -#define S_IFREG 0100000 /* regular */ -#define S_IFBLK 0060000 /* block special */ -#define S_IFDIR 0040000 /* directory */ -#define S_IFCHR 0020000 /* character special */ -#define S_IFIFO 0010000 /* this is a FIFO */ -#define S_ISUID 0004000 /* set user id on execution */ -#define S_ISGID 0002000 /* set group id on execution */ - /* next is reserved for future use */ -#define S_ISVTX 01000 /* save swapped text even after use */ - -/* POSIX masks for st_mode. */ -#define S_IRWXU 00700 /* owner: rwx------ */ -#define S_IRUSR 00400 /* owner: r-------- */ -#define S_IWUSR 00200 /* owner: -w------- */ -#define S_IXUSR 00100 /* owner: --x------ */ - -#define S_IRWXG 00070 /* group: ---rwx--- */ -#define S_IRGRP 00040 /* group: ---r----- */ -#define S_IWGRP 00020 /* group: ----w---- */ -#define S_IXGRP 00010 /* group: -----x--- */ - -#define S_IRWXO 00007 /* others: ------rwx */ -#define S_IROTH 00004 /* others: ------r-- */ -#define S_IWOTH 00002 /* others: -------w- */ -#define S_IXOTH 00001 /* others: --------x */ - -/* The following macros test st_mode (from POSIX Sec. 5.6.1.1. */ -#define S_ISREG(m) ((m & S_IFMT) == S_IFREG) /* is a reg file */ -#define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR) /* is a directory */ -#define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR) /* is a char spec */ -#define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK) /* is a block spec */ -#define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO) /* is a pipe/FIFO */ - - -/* Function Prototypes. */ -#ifndef _ANSI_H -#include <ansi.h> -#endif - -_PROTOTYPE( int chmod, (const char *_path, int _mode) ); -_PROTOTYPE( int fstat, (int _fildes, struct stat *_buf) ); -_PROTOTYPE( int mkdir, (const char *_path, int _mode) ); -_PROTOTYPE( int mkfifo, (const char *_path, int _mode) ); -_PROTOTYPE( int stat , (const char *_path, struct stat *_buf) ); -_PROTOTYPE( mode_t umask, (int _cmask) ); - -#endif /* _STAT_H */ diff --git a/include/mpw/sys/file.h b/include/mpw/sys/file.h deleted file mode 100644 index 40a8c178f10..00000000000 --- a/include/mpw/sys/file.h +++ /dev/null @@ -1 +0,0 @@ -/* empty */ diff --git a/include/mpw/sys/param.h b/include/mpw/sys/param.h deleted file mode 100644 index 40a8c178f10..00000000000 --- a/include/mpw/sys/param.h +++ /dev/null @@ -1 +0,0 @@ -/* empty */ diff --git a/include/mpw/sys/resource.h b/include/mpw/sys/resource.h deleted file mode 100644 index d39439d61d5..00000000000 --- a/include/mpw/sys/resource.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef __SYS_RESOURCE_H__ -#define __SYS_RESOURCE_H__ - -struct rusage { - struct timeval ru_utime; - struct timeval ru_stime; -}; - -#endif /* __SYS_RESOURCE_H__ */ diff --git a/include/mpw/sys/stat.h b/include/mpw/sys/stat.h deleted file mode 100644 index b65c72e10c6..00000000000 --- a/include/mpw/sys/stat.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Imitation sys/stat.h. */ - -#ifndef __SYS_STAT_H__ -#define __SYS_STAT_H__ - -#include <sys/types.h> -#include <time.h> - -struct stat { - dev_t st_dev; - ino_t st_ino; - mode_t st_mode; - short st_nlink; - uid_t st_uid; - gid_t st_gid; - dev_t st_rdev; - off_t st_size; - off_t st_rsize; - time_t st_atime; - int st_spare1; - time_t st_mtime; - int st_spare2; - time_t st_ctime; - int st_spare3; - long st_blksize; - long st_blocks; - long st_spare4[2]; -}; - -#define S_IFMT 0170000L -#define S_IFDIR 0040000L -#define S_IFREG 0100000L -#define S_IREAD 0400 -#define S_IWRITE 0200 -#define S_IEXEC 0100 - -#define S_IFIFO 010000 /* FIFO special */ -#define S_IFCHR 020000 /* character special */ -#define S_IFBLK 030000 /* block special */ - -int stat (char *path, struct stat *buf); -int fstat (int fd, struct stat *buf); - -#endif /* __SYS_STAT_H___ */ diff --git a/include/mpw/sys/time.h b/include/mpw/sys/time.h deleted file mode 100644 index f9e485232a2..00000000000 --- a/include/mpw/sys/time.h +++ /dev/null @@ -1,13 +0,0 @@ -/* Imitation sys/time.h. */ - -#ifndef __SYS_TIME_H__ -#define __SYS_TIME_H__ - -#include <time.h> - -struct timeval { - long tv_sec; - long tv_usec; -}; - -#endif /* __SYS_TIME_H__ */ diff --git a/include/mpw/sys/types.h b/include/mpw/sys/types.h deleted file mode 100644 index d7d9c9f44ba..00000000000 --- a/include/mpw/sys/types.h +++ /dev/null @@ -1,15 +0,0 @@ -/* Imitation sys/types.h. */ - -#ifndef __SYS_TYPES_H__ -#define __SYS_TYPES_H__ - -#include <Types.h> - -typedef short dev_t; -typedef short ino_t; -typedef unsigned short mode_t; -typedef unsigned short uid_t; -typedef unsigned short gid_t; -typedef long off_t; - -#endif /* __SYS_TYPES_H__ */ diff --git a/include/mpw/utime.h b/include/mpw/utime.h deleted file mode 100644 index e8bf66f2ba5..00000000000 --- a/include/mpw/utime.h +++ /dev/null @@ -1,7 +0,0 @@ - -struct utimbuf { - time_t actime; - time_t modtime; -}; - -int utime (char *, struct utimbuf *); diff --git a/include/mpw/varargs.h b/include/mpw/varargs.h deleted file mode 100644 index acb9e4504a2..00000000000 --- a/include/mpw/varargs.h +++ /dev/null @@ -1,9 +0,0 @@ -/* varargs.h. */ -#ifndef __va_list__ -#define __va_list__ -typedef char *va_list; -#endif -#define va_dcl int va_alist; -#define va_start(list) list = (char *) &va_alist -#define va_end(list) -#define va_arg(list,mode) ((mode *)(list += sizeof(mode)))[-1] diff --git a/mpw-README b/mpw-README deleted file mode 100644 index 767140b5b26..00000000000 --- a/mpw-README +++ /dev/null @@ -1,376 +0,0 @@ -This is basic information about the Macintosh(tm) MPW(tm) port of the -GNU tools. The information below applies to both native and cross -compilers. - -(Please note that there are two versions of this file; "mpw-README" -is the source form, and "Read Me for MPW" is the distribution form. -"Read Me for MPW" has 8-bit chars such as \Option-d embedded in it.) - -INSTALLING GNU TOOLS - -* System Requirements - -To use these tools, you will need a Mac with a 68020 or better or else -any PowerMac, System 7.1 or later, and MPW 3.3 or 3.4. You will *not* -need any other MPW compiler unless you want to rebuild from sources, -nor even any include files, unless you are building actual Mac -applications. For PowerMac native you will need PPCLink, however; -also the executables are PowerPC-only. - -* Automated Installation - -The simplest way to install GNU tools is to run the Install script. -The script will copy things to where you want to keep them, will build -a UserStartup file with settings corresponding to where things were -copied, and offer to put that UserStartup file in your MPW folder. - -The Install script does not alter anything in the System Folder, and -it does not take any action without confirmation. - -The Install script will be at the top level of the binary -distribution, or at the top level of the object directory if -rebuilding from source. (The sources include a file called -"mpw-install" at the top level, but it is the source to the Install -script and cannot be run directly.) - -* Manual Installation - -If you don't want to run the Install script, you can do installation -manually; this section describes the steps involved. - -The GNU tools can go in any directory that is in your {Commands} list. -We generally put all the tools somewhere like {Boot}Cygnus:latest:bin, -and then add to a UserStartup file: - - set Commands "{Boot}Cygnus:latest:bin:,{Commands}" - -However, the cpp and cc1 programs of GCC are not normally stored here. -Instead, they will be in a "lib" directory that is alongside "bin", -and organized by target and version underneath, with names like - - :lib:gcc-lib:<target>:cygnus-<version>: - -If you build and install everything yourself according to the build -instructions below, then you will not have any problems. However, you -may discover that GCC seems unable to find the right cpp and cc1; -usually this will be because directory names have changed. (Even -renaming your hard disk will make this happen.) In such cases, you -have several choices. One is just to add this directory to -{Commands}, but then you will not be able to get any other cpp or cc1, -such as those used by a different target or version. Another way is -to rename your disk and directories to match the prefix used when the -tools were compiled. Finally, you can set the variable -GCC_EXEC_PREFIX to point to the library directory: - - set GCC_EXEC_PREFIX MyDisk:Stuff:lib:gcc-lib: - export GCC_EXEC_PREFIX - -You may also want to edit MPW's HEXA 128 resource. When GCC is built -using a native GCC, it is compiled to use a special stack allocator -function alloca(). While this is very efficient, it means that GCC -will need considerable stack space to run, especially when compiling -large programs with optimization turned on. You give MPW more stack -by editing the HEXA 128 resource of the MPW Shell. A value of "0008 -0000" gives 512K of stack size, which is usually sufficient. - -USING GNU TOOLS - -* Using Native PowerMac GCC - -Using a native PowerMac GCC to produce MPW tools or MacOS applications -is more complicated than just "gC foo.c", although no more complicated -than with other Mac compilers. - -To build a native PowerMac MPW tool, use this sequence, where hello.c -is the usual "hello world" program, and genericcfrg.r is the Rez file -with the code fragment resource: - -gC -I{CIncludes} -fno-builtin -Dpascal= -c -g hello.c -PPCLink hello.o -o hello \Option-d - "{PPCLibraries}"StdCRuntime.o \Option-d - "{SharedLibraries}"InterfaceLib \Option-d - "{SharedLibraries}"StdCLib \Option-d - "{PPCLibraries}"PPCToolLibs.o \Option-d - "{PPCLibraries}"PPCCRuntime.o \Option-d - "{GCCPPCLibraries}"libgcc.xcoff -rez -d APPNAME='"'hello'"' GenericCFRG.r -o hello -setfile -t 'MPST' -c 'MPS ' hello - -The same sequence works to build a MacOS application, but you set the file -type to 'APPL' and don't link in PPCToolLibs.o. For further details on -using MPW to build Mac applications, see the general MPW documentation. - -Recent versions of PPCLink have an option to generate the code -fragment resource and automatically set creator and file type; -here is what GenericCFRG.r should look like if you have an older -PPCLink or are using GNU ld: - -#include "CodeFragmentTypes.r" - -resource 'cfrg' (0) { - { - kPowerPC, - kFullLib, - kNoVersionNum,kNoVersionNum, - 0,0, - kIsApp,kOnDiskFlat,kZeroOffset,kWholeFork, - APPNAME // must be defined on Rez command line with -d option - } -}; - -In general this port of GCC supports the same option syntax and -behavior as its Unix counterpart. It also has similar compilation -rules, so it will run the assembler on .s files and so forth. - -The GCC manual includes full information on the available options. -One option that may be especially useful is "-v", which shows you what -tools and options are being used; unlike most Mac C compilers, GCC -directs assembly and linking in addition to compilation. - -MPW GCC does feature two extensions to the option syntax; '-d macro=name' -works just as '-Dmacro=name' does in Unix, and '-i directory' works the -same as '-Idirectory'. - -MPW GCC supports the usual Pascal-style strings and alignment pragmas. - -To find standard include files you can set the variable GCCIncludes: - - set GCCIncludes MyDisk:MyIncludes: - export GCCIncludes - -GCCIncludes is similar to MPW's CIncludes or CW's MWCIncludes. In -order to use MPW's usual include files, just say: - - set GCCIncludes "{CIncludes}" - export GCCIncludes - -* Using GCC as a Cross-Compiler - -If you have a cross-compiler, and you have all of the correct -target-side crt0 and libraries available, then to compile and link a -file "foo.c", you can say just - - gC foo.c - -The output file will be an MPW binary file named "a.out"; the format -of the contents will depend on which target is in use, so for instance -a MIPS-targeting GCC will produce ECOFF or ELF executables. - -Note that using MPW include files with a cross-compiler is somewhat -dangerous. - -* Using the Assembler and Friends - -The assembler ("as") and linker ("ld") are faithful ports of their -Unix counterparts. Similarly, the binutils "ar", "cplusfilt", "nm", -"objcopy", "objdump", "ranlib", "size", "strings", and "strip" are all -like they are under Unix. (Note that "cplusfilt" is usually called -"c++filt" under Unix.) - -* Using GDB - -There are two flavors of GDB. "gdb" is an MPW tool that works very -much like it does in Unix; put a command into the MPW worksheet and -type the <enter> key to send it to GDB. While "gdb" is running, you -cannot do anything else in MPW, although you can switch to other -Mac applications and use them. - -"SiowGDB" is also a Mac application, but it is GDB using the SIOW -package to provide console emulation. Commands are exactly as for the -MPW tool, but since this is its own application, you can switch -between it and MPW. - -BUILDING GNU TOOLS - -This port of the GNU tools uses a configure script similar to -that used for GNU tools under Unix, but rewritten for MPW. As with -Unix configuration, there is an "object" directory that may be -different from the "source" directory. In the example commands below, -we will assume that we are currently in the object directory, and that -the source directory is "{Boot}Cygnus:src:". - -* Requirements for Building - -In addition to the sources, you will need a set of tools that the -configure and build scripts assume to be available. These tools -(and their versions, if relevant) are as follows: - - byacc tool - flex (2.3.7) tool (and Flex.skel file) - forward-include script - MoveIfChange script - mpw-touch script - mpw-true script - NewFolderRecursive script - null-command script - open-brace script - sed (1.13) tool - tr-7to8 script - true script - -The scripts are in the sources, under utils:mpw:. You must arrange to -get the other tools yourself (they are readily available from the -"usual" net sites, and are also on many CDROMS). In addition, there -will usually be a set of these available at ftp.cygnus.com, in pub/mac. - -You may put the build tools in your usual Tools or Scripts -directories, or keep them in a separate directories. We prefer to -make a directory called "buildtools" and we put this in one of our -UserStartup files: - - set Commands "{Boot}Cygnus:buildtools:,{Commands}" - -Flex uses an environment variable FLEX_SKELETON to locate its skeleton -file, so you need to do something like this, preferably in a UserStartup: - - Set FLEX_SKELETON "{Boot}"Cygnus:buildtools:Flex.skel - Export FLEX_SKELETON - -* Configuring - -Before you can build anything, you must configure. You do this by -creating an directory where object files will be stored, setdirectory -to that directory and do a configure command: - - {Boot}Cygnus:src:mpw-configure --target <name> --cc <compiler> --srcdir {Boot}Cygnus:src: --prefix <whatever> - -If the source directory is not in your {Commands} list, then you must -supply a full pathname to mpw-configure, since mpw-configure invokes -itself after switching into each subdirectory. Using a relative -pathname, even something like ':mpw-configure', will therefore not work. - -<name> must be a known target. Valid ones include "m68k-apple-macos", -"powerpc-apple-macos", "i386-unknown-go32", "mips-idt-ecoff", and -"sh-hitachi-hms". Not all target types are accepted for all of the -tools yet. - -<compiler> must be the name of the compiler to use. It defaults to "mpwc". - - (m68k) - mpwc MPW C - sc68k Symantec C - mwc68k Metrowerks C (Codewarrior) - gcc68k GCC - - (powerpc) - ppcc PPCC - mrc Macintosh on RisC (Mister C, aka(?) Frankenstein) - scppc Symantec C - mwcppc Metrowerks C (Codewarrior) - gccppc GCC - -Not all compilers will compile all tools equally well! For m68k Macs, -MPW C has the best record so far (it has problems, but they can be -worked around), while for PowerMacs, CodeWarrior is the only compiler -that has successfully compiled everything into running code. - -<prefix> is the path that "gcc" will prepend when looking for tools -to execute. GCC_EXEC_PREFIX overrides this value, so you need not -include it if you plan to use GCC_EXEC_PREFIX. - -As an example, here is the configure line that you could use to build -native PowerMac GCC: - -"{Boot}"Cygnus:src:mpw-configure --cc mwcppc --target powerpc-apple-macos --srcdir "{Boot}"Cygnus:src: --prefix "{Boot}"GNUTools: - -* Building - -If you use CodeWarrior, you *must* first set MWCIncludes to -{CIncludes}. This is because you will be building MPW tools, and -their standard I/O works by making references to data that is part of -the MPW Shell, which means that the code must be compiled and linked -with macros that refer to that data, and those macros are in -{CIncludes}, not the default {MWCIncludes}. Without this change, you -will encounter problems compiling libiberty/mpw.c, but tweaking that -file only masks the real problem, and does not fix it. - -The command - - mpw-build - -will build everything. Building will take over an hour on a Quadra 800 -or PowerMac 8100/110, longer if the sources are on a shared volume. - -You may see some warnings; these are mostly likely benign, typically -disagreements about declarations of library and system functions. - -* Installing - -To install the just-built tools, use the command - - mpw-build install - -This part of the installation procedure just copies files to the -location specified at configure time by <prefix>, and, in some cases, -renames them from temporary internal names to their usual names. This -install process is *not* the same as what the Install script does; -Install can copy tools from the installation location chosen at -configuration time to a user-chosen place, and sets up a UserStartup -file. Note that while the Install script is optional, the install -build action performs some tasks would be very hard to replicate -manually, so you should always do it before using the tools. - -* Known Problems With Using Various Compilers to Build - -Most versions of MPW C have problems with compiling GNU software. - -MPW C 3.2.x has preprocessing bugs that render it incapable of -compiling the BFD library, so it can't be used at all for building BFD. - -MPW C 3.3, 3.3.1, and 3.3.2 will spontaneously claim to have found -errors in the source code, but in fact the code is perfectly fine. If -this happens, just set the working directory back to the top-level -objdir (where the configure command above was performed), and type -"mpw-build all" again. If it goes on through the supposed error, then -you got one of the spurious errors. A full build may require a number -of these restarts. - -MPW C 3.3.3 seems to work OK, at least with the aid of a number of -workarounds that are in the sources (look for #ifdef MPW_C). - -Versions of MPW Make earlier than 4.0d2 have exhibited bizarre behavior, -failure to substitute variables and the like. - -Metrowerks CW6 PPC linker (MWLinkPPC) seems to do bad things with memory -if the "Modern Memory Manager" is turned on (in the Memory control panel), -but works OK if it is turned off. - -Metrowerks CW6 loses bigtime compiling opcodes:ppc-opc.c, which has -some deeply nested macros. (CW7 is OK.) There is a way to patch the -file, by substituting constant values. If you need to do this, -contact shebs@cygnus.com for details. - -<Gestalt.h> is missing from {CIncludes} in the MPW version that comes -with CW7. You can just copy the one in CW7's {MWCIncludes}. - -CW8 and later have changes to headers and such that will require changes -to the source in order to be able to use them to rebuild. - -KNOWN BUGS - -The declarations for memcpy and memcmp in some versions of header files -may conflict with GCC's builtin definition. Either use -fno-builtin -or ignore the warnings. - -This is not a bug, but - watch out for cr/nl translation! For instance, -if config/mpw-mh-mpw is not properly translated because it has been -copied or updated separately, then everything will almost build, but -you will get puzzling error messages from make or the compiler. - -'/' or ' ' embedded in any device, directory, or file name may or may -not work. - -objcopy -O srec foo.o makes random output filenames. - -Mac-x-mips requires -mgas but Unix hosts don't. - -GDB will frequently require a '/' on the front of a device name in order -to recognize it as an absolute rather than a relative pathname. - -GDB doesn't seem to use the printer port correctly, although it tries. - -The cursor doesn't always spin as much as it should. To get elaborate -statistics and warnings about spin rates, add this to UserStartup: - - set MEASURE_SPIN all - export MEASURE_SPIN diff --git a/mpw-build.in b/mpw-build.in deleted file mode 100644 index 86d9530fa3b..00000000000 --- a/mpw-build.in +++ /dev/null @@ -1,204 +0,0 @@ -# Top-level script fragment to build everything for MPW. - -Set savedir "`Directory`" - -#Set Echo 1 - -Set ThisScript "{0}" - -Set objdir ":" - -Set verify 0 - -Set BuildTarget "none" - -# Parse arguments. - -Loop - Break If {#} == 0 - If "{BuildTarget}" =~ /none/ - Set BuildTarget "{1}" - Else - Echo Only one build target allowed, ignoring "{1}" - End If - Shift 1 -End Loop - -If "{BuildTarget}" =~ /none/ - Set BuildTarget "all" -End If - -If {verify} == 1 - Echo "#" Doing "{ThisScript}" "{BuildTarget}" in "`Directory`" ... -End If - -Set ranmake 0 - -If "`Exists Makefile`" != "" - Echo "Set Echo 1" >{BuildTarget}.makeout - Make -f Makefile {BuildTarget} >>{BuildTarget}.makeout - {BuildTarget}.makeout - Delete {BuildTarget}.makeout - Set ranmake 1 -End If - -If "`Exists Makefile.PPC`" != "" - Echo "Set Echo 1" >{BuildTarget}.makeout.ppc - Make -f Makefile.PPC {BuildTarget} >>{BuildTarget}.makeout.ppc - {BuildTarget}.makeout.ppc - Delete {BuildTarget}.makeout.ppc - Set ranmake 1 -End If - -If {ranmake} == 1 - Exit -End If - -# Dispatch on various pseudo-targets. - -If "{BuildTarget}" =~ /all/ - Echo Started `Date` - "{ThisScript}" all-gcc - "{ThisScript}" all-gdb - Echo Finished `Date` -Else If "{BuildTarget}" =~ /all-libiberty/ - "{ThisScript}" do-libiberty -Else If "{BuildTarget}" =~ /all-bfd/ - "{ThisScript}" do-bfd -Else If "{BuildTarget}" =~ /all-opcodes/ - "{ThisScript}" do-opcodes -Else If "{BuildTarget}" =~ /all-byacc/ - "{ThisScript}" do-byacc -Else If "{BuildTarget}" =~ /all-flex/ - "{ThisScript}" all-libiberty - "{ThisScript}" do-flex -Else If "{BuildTarget}" =~ /all-binutils/ - "{ThisScript}" all-libiberty - "{ThisScript}" all-bfd - "{ThisScript}" all-opcodes - "{ThisScript}" do-binutils -Else If "{BuildTarget}" =~ /all-gas/ - "{ThisScript}" all-libiberty - "{ThisScript}" all-bfd - "{ThisScript}" all-opcodes - "{ThisScript}" do-gas -Else If "{BuildTarget}" =~ /all-gcc/ - "{ThisScript}" all-libiberty - "{ThisScript}" all-gas - "{ThisScript}" all-binutils - "{ThisScript}" all-ld - "{ThisScript}" do-gcc -Else If "{BuildTarget}" =~ /all-gdb/ - "{ThisScript}" all-libiberty - "{ThisScript}" all-bfd - "{ThisScript}" all-opcodes - "{ThisScript}" do-gdb -Else If "{BuildTarget}" =~ /all-grez/ - "{ThisScript}" all-libiberty - "{ThisScript}" all-bfd - "{ThisScript}" do-grez -Else If "{BuildTarget}" =~ /all-ld/ - "{ThisScript}" all-libiberty - "{ThisScript}" all-bfd - "{ThisScript}" all-opcodes - "{ThisScript}" do-ld -Else If "{BuildTarget}" =~ /do-byacc/ - SetDirectory :byacc: - ::mpw-build all -Else If "{BuildTarget}" =~ /do-flex/ - SetDirectory :flex: - ::mpw-build _bootstrap - ::mpw-build all -Else If "{BuildTarget}" =~ /do-bfd/ - SetDirectory :bfd: - ::mpw-build all -Else If "{BuildTarget}" =~ /do-libiberty/ - SetDirectory :libiberty: - ::mpw-build all -Else If "{BuildTarget}" =~ /do-opcodes/ - SetDirectory :opcodes: - ::mpw-build all -Else If "{BuildTarget}" =~ /do-binutils/ - SetDirectory :binutils: - ::mpw-build stamps - ::mpw-build all -Else If "{BuildTarget}" =~ /do-gas/ - SetDirectory :gas: - ::mpw-build stamps - ::mpw-build all -Else If "{BuildTarget}" =~ /do-gcc/ - SetDirectory :gcc: - :mpw-build all -Else If "{BuildTarget}" =~ /do-gdb/ - SetDirectory :gdb: - ::mpw-build all -Else If "{BuildTarget}" =~ /do-grez/ - SetDirectory :grez: - ::mpw-build all -Else If "{BuildTarget}" =~ /do-ld/ - SetDirectory :ld: - ::mpw-build all -Else If "{BuildTarget}" =~ /do-newlib/ - SetDirectory :newlib: - ::mpw-build all -Else If "{BuildTarget}" =~ /install/ - "{ThisScript}" install-only-top - "{ThisScript}" install-binutils - "{ThisScript}" install-gas - "{ThisScript}" install-gcc - "{ThisScript}" install-ld - "{ThisScript}" install-gdb -Else If "{BuildTarget}" =~ /install-binutils/ - SetDirectory :binutils: - ::mpw-build install -Else If "{BuildTarget}" =~ /install-gas/ - SetDirectory :gas: - ::mpw-build install -Else If "{BuildTarget}" =~ /install-gcc/ - SetDirectory :gcc: - :mpw-build install -Else If "{BuildTarget}" =~ /install-gdb/ - SetDirectory :gdb: - ::mpw-build install -Else If "{BuildTarget}" =~ /install-grez/ - SetDirectory :grez: - ::mpw-build install -Else If "{BuildTarget}" =~ /install-ld/ - SetDirectory :ld: - ::mpw-build install -Else If "{BuildTarget}" =~ /install-only/ - "{ThisScript}" install-only-top - "{ThisScript}" install-only-binutils - "{ThisScript}" install-only-gas - "{ThisScript}" install-only-gcc - "{ThisScript}" install-only-gdb - "{ThisScript}" install-only-ld -Else If "{BuildTarget}" =~ /install-only-binutils/ - SetDirectory :binutils: - ::mpw-build install-only -Else If "{BuildTarget}" =~ /install-only-gas/ - SetDirectory :gas: - ::mpw-build install-only -Else If "{BuildTarget}" =~ /install-only-gcc/ - SetDirectory :gcc: - :mpw-build install-only -Else If "{BuildTarget}" =~ /install-only-gdb/ - SetDirectory :gdb: - ::mpw-build install-only -Else If "{BuildTarget}" =~ /install-only-grez/ - SetDirectory :grez: - ::mpw-build install-only -Else If "{BuildTarget}" =~ /install-only-ld/ - SetDirectory :ld: - ::mpw-build install-only -Else If "{BuildTarget}" =~ /install-only-top/ - NewFolderRecursive "{prefix}" - If "{prefix}" != "`Directory`" - Duplicate -y 'Read Me for MPW' "{prefix}"'Read Me for MPW' - Duplicate -y Install "{prefix}"Install - End If -Else - Echo {BuildTarget} not understood, ignoring -End If - -SetDirectory "{savedir}" diff --git a/mpw-config.in b/mpw-config.in deleted file mode 100644 index 8028737a8b6..00000000000 --- a/mpw-config.in +++ /dev/null @@ -1,113 +0,0 @@ -# Configuration fragment for Cygnus source tree. - -# Check that we can find all the special tools that we will need. -# The test for sed is semi-pointless, because it's already been invoked -# by the calculation of target_cpu in the main configure script, but -# the test will also show which one is being used. - -Set Exit 0 -Echo byacc is `Which byacc` -Echo flex is `Which flex` -Echo forward-include is `Which forward-include` -Echo MoveIfChange is `Which MoveIfChange` -Echo mpw-touch is `Which mpw-touch` -Echo mpw-true is `Which mpw-true` -Echo NewFolderRecursive is `Which NewFolderRecursive` -Echo null-command is `Which null-command` -Echo open-brace is `Which open-brace` -Echo sed is `Which sed` -Echo 'tr-7to8' is `Which tr-7to8` -Echo true is `Which true` -Set Exit 1 - -Set host_libs "mmalloc libiberty opcodes bfd readline gash tcl tk tclX" - -Set host_tools "texinfo byacc flex bison binutils ld gas gcc gdb make patch \Option-d - prms send-pr gprof gdbtest tgas etc expect dejagnu sim bash \Option-d - m4 autoconf ispell grep diff rcs cvs fileutils shellutils time \Option-d - textutils wdiff find emacs emacs19 uudecode hello tar gzip indent \Option-d - recode release sed utils guile perl apache inet gawk" - -Set target_libs "newlib" - -Set target_tools "examples" - -# Configure the resource compiler if targeting Macs. -If {target_os} =~ /macos/ || {target_os} =~ /mpw/ - Set host_tools "{host_tools} grez" -End If - -Set configdirs "{host_libs} {host_tools} {target_libs} {target_tools}" -Export configdirs - -# Make up a special include directory that tools will share. - -If "`Exists "{objdir}"extra-include`" == "" - NewFolder "{objdir}"extra-include -End If - -Set edir "{objdir}extra-include:" - -forward-include "{srcdir}"include:mpw:sys:file.h "{edir}"'sys/file.h' -forward-include "{srcdir}"include:mpw:sys:ioctl.h "{edir}"'sys/ioctl.h' -forward-include "{srcdir}"include:mpw:sys:param.h "{edir}"'sys/param.h' -forward-include "{srcdir}"include:mpw:sys:resource.h "{edir}"'sys/resource.h' -forward-include "{srcdir}"include:mpw:sys:stat.h "{edir}"'sys/stat.h' -forward-include "{srcdir}"include:mpw:sys:time.h "{edir}"'sys/time.h' -forward-include "{srcdir}"include:mpw:sys:types.h "{edir}"'sys/types.h' - -forward-include "{srcroot}"include:aout:aout64.h "{edir}"'aout/aout64.h' -forward-include "{srcroot}"include:aout:ar.h "{edir}"'aout/ar.h' -forward-include "{srcroot}"include:aout:ranlib.h "{edir}"'aout/ranlib.h' -forward-include "{srcroot}"include:aout:reloc.h "{edir}"'aout/reloc.h' -forward-include "{srcroot}"include:aout:stab.def "{edir}"'aout/stab.def' -forward-include "{srcroot}"include:aout:stab_gnu.h "{edir}"'aout/stab_gnu.h' - -If "`Exists "{srcroot}"include:aout:"{target_cpu}".h`" != "" - forward-include "{srcroot}"include:aout:"{target_cpu}".h "{edir}"'aout/'"{target_cpu}"'.h' -End If - -forward-include "{srcroot}"include:coff:ecoff.h "{edir}"'coff/ecoff.h' -forward-include "{srcroot}"include:coff:internal.h "{edir}"'coff/internal.h' -forward-include "{srcroot}"include:coff:sym.h "{edir}"'coff/sym.h' -forward-include "{srcroot}"include:coff:symconst.h "{edir}"'coff/symconst.h' - -If "`Exists "{srcroot}"include:coff:"{target_cpu}".h`" != "" - forward-include "{srcroot}"include:coff:"{target_cpu}".h "{edir}"'coff/'"{target_cpu}"'.h' -End If -If "{target_cpu}" =~ /powerpc/ - forward-include "{srcroot}"include:coff:rs6000.h "{edir}"'coff/rs6000.h' -End If - -forward-include "{srcroot}"include:elf:common.h "{edir}"'elf/common.h' -forward-include "{srcroot}"include:elf:dwarf.h "{edir}"'elf/dwarf.h' -forward-include "{srcroot}"include:elf:dwarf2.h "{edir}"'elf/dwarf2.h' -forward-include "{srcroot}"include:elf:external.h "{edir}"'elf/external.h' -forward-include "{srcroot}"include:elf:internal.h "{edir}"'elf/internal.h' - -# Believe it or not, GDB needs this for all targets. -forward-include "{srcroot}"include:elf:mips.h "{edir}"'elf/mips.h' - -If "`Exists "{srcroot}"include:elf:"{target_cpu}".h`" != "" - forward-include "{srcroot}"include:elf:"{target_cpu}".h "{edir}"'elf/'"{target_cpu}"'.h' -End If -If "{target_cpu}" =~ /powerpc/ - forward-include "{srcroot}"include:elf:ppc.h "{edir}"'elf/ppc.h' -End If - -If "`Exists "{srcroot}"include:opcode:"{target_cpu}".h`" != "" - forward-include "{srcroot}"include:opcode:"{target_cpu}".h "{edir}"'opcode/'"{target_cpu}"'.h' -End If -If "{target_cpu}" =~ /powerpc/ - forward-include "{srcroot}"include:opcode:ppc.h "{edir}"'opcode/ppc.h' -End If - -# Add some bfd includes that get mentioned outside the bfd dir. - -forward-include "{srcroot}"bfd:libcoff.h "{edir}"'bfd/libcoff.h' -forward-include "{srcroot}"bfd:libecoff.h "{edir}"'bfd/libecoff.h' - -# Translate random files into MPW-only character set. - -tr-7to8 "{srcdir}"mpw-README > "{objdir}Read Me for MPW" -tr-7to8 "{srcdir}"mpw-install > "{objdir}"Install diff --git a/mpw-configure b/mpw-configure deleted file mode 100644 index cf45148ec63..00000000000 --- a/mpw-configure +++ /dev/null @@ -1,448 +0,0 @@ -# Configuration script -# Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc. - -# 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 2 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, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - -### WARNING -### This script must NOT use any 8-bit chars! -### WARNING - -# This is an MPW Shell script that sets everything up for compilation, -# mainly creating directories, and editing copies of files. - -Set savedir "`Directory`" - -#Set Echo 1 - -Set ThisScript "{0}" - -Set srcroot "--------" - -Set srcdir ":" - -Set objdir ":" - -Set prefix "{MPW}":GNUTools: - -Set exec_prefix "" - -Set bindir "" - -Set host_alias "m68k-apple-mpw" - -Set target_alias {host_alias} - -Set host_cc "mpwc" - -Set with_gnu_ld 0 - -Set helpoutput 0 - -Set recurse 1 - -Set verify 0 -Set verifystr "" - -Set enable_options "" -Set disable_options "" - -# Parse arguments. - -Loop - Break If {#} == 0 - If "{1}" =~ /--cc/ - Set host_cc "{2}" - Shift 1 - Else If "{1}" =~ /--bindir/ - Set bindir "{2}" - Shift 1 - Else If "{1}" =~ /--disable-?+/ - Set `Echo {1} | sed -e 's/--disable-/enable_/'` no - Set disable_options "{disable_options} '{1}'" - Else If "{1}" =~ /--enable-?+/ - Set `Echo {1} | sed -e 's/--enable-/enable_/'` yes - Set enable_options "{enable_options} '{1}'" - Else If "{1}" =~ /--exec-prefix/ - Set exec_prefix "{2}" - Shift 1 - Else If "{1}" =~ /--help/ - Set helpoutput 1 - Else If "{1}" =~ /--host/ - Set host_alias "{2}" - Shift 1 - Else If "{1}" =~ /--norecursion/ - Set recurse 0 - Else If "{1}" =~ /--prefix/ - Set prefix "{2}" - Shift 1 - Else If "{1}" =~ /--srcdir/ - Set srcdir "{2}" - Shift 1 - Else If "{1}" =~ /--srcroot/ - Set srcroot "{2}" - Shift 1 - Else If "{1}" =~ /--target/ - Set target_alias "{2}" - Shift 1 - Else If "{1}" =~ /-v/ - Set verify 1 - Set verifystr "-v" - Else If "{1}" =~ /--with-gnu-ld/ - Set with_gnu_ld 1 - Else - Echo -n 'mpw-configure: Unrecognized option: "' - Echo -n "{1}" - Echo '"; use --help for usage.' - Exit 1 - End If - Shift 1 -End Loop - -If {helpoutput} == 1 - Echo "Usage: mpw-configure [OPTIONS]" - Echo "" - Echo "Options: [defaults in brackets]" - Echo "--bindir DIR directory for binaries []" - Echo "--cc CC use C compiler CC [mpwc]" - Echo "--disable-FOO do not include feature FOO" - Echo "--enable-FOO include feature FOO" - Echo "--exec-prefix DIR install host-dependent files into DIR []" - Echo "--help print this message" - Echo "--host HOST configure for HOST [m68k-apple-mpw]" - Echo "--norecursion configure this directory only [recurse]" - Echo "--prefix DIR install into DIR [{MPW}:GNUTools:]" - Echo "--srcdir DIR find the sources in DIR [:]" - Echo "--srcroot DIR find the toplevel sources in DIR [:]" - Echo "--target TARGET configure for TARGET [TARGET=HOST]" - Echo "-v verbose" - Echo "--with-gnu-ld link using GNU ld [no]" - Exit 0 -End If - -Set Exit 0 - -# Default exec_prefix from prefix. - -If "{exec_prefix}" == "" - Set exec_prefix "{prefix}" -End If - -If "{bindir}" == "" - Set bindir "{prefix}"bin: -End If - -# Point to the correct set of tools to use with the chosen compiler. - -If "{host_cc}" =~ /mpwc/ - Set host_alias "m68k-apple-mpw" - Set cc_name '{CC_MPW_C}' - Set segment_flag '-s ' - Set ar_name '{AR_LIB}' - Set ranlib_name '{RANLIB_NULL}' - Set cc_ld_name '{CC_LD_LINK}' - Set prog_ext_name '{PROG_EXT_68K}' - Set extralibs_name '{EXTRALIBS_C}' - Set makepef_name '{MAKEPEF_NULL}' - Set rez_name '{REZ_68K}' -Else If "{host_cc}" =~ /sc68k/ - Set host_alias "m68k-apple-mpw" - Set cc_name '{CC_SC}' - Set segment_flag '-s ' - Set ar_name '{AR_LIB}' - Set ranlib_name '{RANLIB_NULL}' - Set cc_ld_name '{CC_LD_LINK}' - Set prog_ext_name '{PROG_EXT_68K}' - Set extralibs_name '{EXTRALIBS_C}' - Set makepef_name '{MAKEPEF_NULL}' - Set rez_name '{REZ_68K}' -Else If "{host_cc}" =~ /mwc68k/ - Set host_alias "m68k-apple-mpw" - Set cc_name '{CC_MWC68K}' - Set segment_flag '-s ' - Set ar_name '{AR_MWLINK68K}' - Set ranlib_name '{RANLIB_NULL}' - Set cc_ld_name '{CC_LD_MWLINK68K}' - Set prog_ext_name '{PROG_EXT_68K}' - Set extralibs_name '{EXTRALIBS_MWC68K}' - Set makepef_name '{MAKEPEF_NULL}' - Set rez_name '{REZ_68K}' -Else If "{host_cc}" =~ /gcc68k/ - Set host_alias "m68k-apple-mpw" - Set cc_name '{CC_68K_GCC}' - Set segment_flag '-s ' - Set ar_name '{AR_68K_AR}' - Set ranlib_name '{RANLIB_RANLIB}' - Set cc_ld_name '{CC_68K_GCC}' - Set prog_ext_name '{PROG_EXT_68K}' - Set extralibs_name '{EXTRALIBS_C}' - Set makepef_name '{MAKEPEF_NULL}' - Set rez_name '{REZ_68K}' -Else If "{host_cc}" =~ /ppcc/ - Set host_alias "powerpc-apple-mpw" - Set cc_name '{CC_PPCC}' - Set segment_flag '-d ___s_e_g___=' - Set ar_name '{AR_PPCLINK}' - Set ranlib_name '{RANLIB_NULL}' - Set cc_ld_name '{CC_LD_PPCLINK}' - Set prog_ext_name '{PROG_EXT_XCOFF}' - Set extralibs_name '{EXTRALIBS_PPC}' - Set makepef_name '{MAKEPEF_PPC}' - Set rez_name '{REZ_PPC}' -Else If "{host_cc}" =~ /mrc/ - Set host_alias "powerpc-apple-mpw" - Set cc_name '{CC_MRC}' - Set segment_flag '-d ___s_e_g___=' - Set ar_name '{AR_PPCLINK}' - Set ranlib_name '{RANLIB_NULL}' - Set cc_ld_name '{CC_LD_PPCLINK}' - Set prog_ext_name '{PROG_EXT_XCOFF}' - Set extralibs_name '{EXTRALIBS_PPC}' - Set makepef_name '{MAKEPEF_PPC}' - Set rez_name '{REZ_PPC}' -Else If "{host_cc}" =~ /scppc/ - Set host_alias "powerpc-apple-mpw" - Set cc_name '{CC_SC}' - Set segment_flag '-d ___s_e_g___=' - Set ar_name '{AR_PPCLINK}' - Set ranlib_name '{RANLIB_NULL}' - Set cc_ld_name '{CC_LD_PPCLINK}' - Set prog_ext_name '{PROG_EXT_XCOFF}' - Set extralibs_name '{EXTRALIBS_PPC}' - Set makepef_name '{MAKEPEF_PPC}' - Set rez_name '{REZ_PPC}' -Else If "{host_cc}" =~ /mwcppc/ - Set host_alias "powerpc-apple-mpw" - Set cc_name '{CC_MWCPPC}' - Set segment_flag '-d ___s_e_g___=' - Set ar_name '{AR_MWLINKPPC}' - Set ranlib_name '{RANLIB_NULL}' - Set cc_ld_name '{CC_LD_MWLINKPPC}' - # Misleading, but we don't need a PEF step. - Set prog_ext_name '{PROG_EXT_68K}' - Set extralibs_name '{EXTRALIBS_MWCPPC}' - Set makepef_name '{MAKEPEF_NULL}' - Set rez_name '{REZ_PPC}' -Else If "{host_cc}" =~ /gccppc/ - Set host_alias "powerpc-apple-mpw" - Set cc_name '{CC_PPC_GCC}' - Set segment_flag '-d ___s_e_g___=' - Set ar_name '{AR_PPCLINK}' - If {with_gnu_ld} == 1 - Set ranlib_name '{RANLIB_RANLIB}' - Set cc_ld_name '{CC_LD_GLD}' - Else - Set ranlib_name '{RANLIB_NULL}' - Set cc_ld_name '{CC_LD_PPCLINK}' - End If - Set prog_ext_name '{PROG_EXT_XCOFF}' - Set extralibs_name '{EXTRALIBS_PPC}' - Set makepef_name '{MAKEPEF_PPC}' - Set rez_name '{REZ_PPC}' -Else - Echo "{host_cc}" is not a known MPW compiler type -End If - -Set dash_c_flag '' -If "{host_cc}" =~ /gcc68k/ - Set dash_c_flag '-c' -Else If "{host_cc}" =~ /gccppc/ - Set dash_c_flag '-c' -End If - -# (should interpret aliases if not in canonical form) - -Set host_canonical "{host_alias}" - -Set target_canonical "{target_alias}" - -Set configdirs "" - -If "{srcroot}" =~ /--------/ - Set srcroot "{srcdir}" -End If -If "`Exists "{srcdir}"`" == "" - Echo Source directory {srcdir} does not exist! - Exit 1 -End If -If "`Exists "{srcroot}"`" == "" - Echo Top-level source directory {srcroot} does not exist! - Exit 1 -End If - -Set target_cpu "`echo {target_canonical} | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\1/'`" -Set target_vendor "`echo {target_canonical} | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\2/'`" -Set target_os "`echo {target_canonical} | sed 's/^\(.*\)-\(.*\)-\(.*\)$/\3/'`" - -# Create a file that is guaranteed to be older than any other here. - -If "`Exists "{objdir}"_oldest`" == "" - mpw-touch _oldest -End If - -# Record this before creating any files, makefiles sometimes mention -# dependencies on config.status. - -Echo "# This directory was configured as follows:" >config.new -Echo "{ThisScript} --host {host_alias} --target {target_alias} --srcdir {srcdir} --srcroot {srcroot} --prefix {prefix} --cc {host_cc} {verifystr} {enable_options} {disable_options} --norecursion" >>config.new -MoveIfChange config.new config.status - -If "`Exists "{srcdir}"mpw-config.in`" != "" - tr-7to8 "{srcdir}"mpw-config.in >"{objdir}"mpw-config.in - Execute "{objdir}"mpw-config.in -End If - -# Start Makefile construction by defining all the variables chosen by -# configuration. - -Echo "# This Makefile produced by mpw-configure. Changes may get lost!" > "{objdir}"Makefile.tem -Echo "srcroot = " {srcroot} >> "{objdir}"Makefile.tem -Echo "topsrcdir = " {srcroot} >> "{objdir}"Makefile.tem -Echo "srcdir = " {srcdir} >> "{objdir}"Makefile.tem -Echo "mpw_prefix = " {prefix} >> "{objdir}"Makefile.tem -Echo "mpw_exec_prefix = " {exec_prefix} >> "{objdir}"Makefile.tem -Echo "mpw_bindir = " {bindir} >> "{objdir}"Makefile.tem -Echo "host_alias = " {host_alias} >> "{objdir}"Makefile.tem -Echo "target_alias = " {target_alias} >> "{objdir}"Makefile.tem -Echo "target_cpu = " {target_cpu} >> "{objdir}"Makefile.tem -Echo "target_vendor = " {target_vendor} >> "{objdir}"Makefile.tem -Echo "target_os = " {target_os} >> "{objdir}"Makefile.tem -Echo "target_canonical = " {target_canonical} >> "{objdir}"Makefile.tem -Echo "host_makefile_frag = " >> "{objdir}"Makefile.tem -Echo "target_makefile_frag = " >> "{objdir}"Makefile.tem -Echo "CC = " {cc_name} >> "{objdir}"Makefile.tem -Echo "AR = " {ar_name} >> "{objdir}"Makefile.tem -Echo "RANLIB = " {ranlib_name} >> "{objdir}"Makefile.tem -Echo "CC_LD = " {cc_ld_name} >> "{objdir}"Makefile.tem -Echo "PROG_EXT = " {prog_ext_name} >> "{objdir}"Makefile.tem -Echo "EXTRALIBS = " {extralibs_name} >> "{objdir}"Makefile.tem -Echo "MAKEPEF = " {makepef_name} >> "{objdir}"Makefile.tem -Echo "REZ = " {rez_name} >> "{objdir}"Makefile.tem - -If {host_cc} =~ /gccppc/ - Echo -n "dq =\Option-d\Option-d\Option-d" > "{objdir}"Makefile.tem0 - Echo '"' >> "{objdir}"Makefile.tem0 - tr-7to8 "{objdir}"Makefile.tem0 >>"{objdir}"Makefile.tem -Else - Echo -n "dq ='" >> "{objdir}"Makefile.tem - Echo -n '"' >> "{objdir}"Makefile.tem - Echo "'" >> "{objdir}"Makefile.tem -End If - -# Append the master set of definitions for the various compilers. - -If "`Exists "{srcdir}"config:mpw-mh-mpw`" != "" - tr-7to8 "{srcdir}"config:mpw-mh-mpw >>"{objdir}"Makefile.tem -Else If "`Exists "{srcroot}"config:mpw-mh-mpw`" != "" - tr-7to8 "{srcroot}"config:mpw-mh-mpw >>"{objdir}"Makefile.tem -Else - Echo "can't find a host config file!" - Exit 0 -End If - -# Append anything produced by the directory's mpw-config.in. - -If "`Exists "{objdir}"mk.tmp`" != "" - Catenate "{objdir}"mk.tmp >>"{objdir}"Makefile.tem - # An mpw-config.in might change so as not to create this - # anymore, so get rid of it now to be safe. - Delete -i -y "{objdir}"mk.tmp -End If - -# If there are sed scripts to edit the Unix Makefile.in, use them; otherwise -# use an mpw-make.in if present. - -If "`Exists "{srcdir}"mpw-make.sed`" != "" - If "`Exists "{objdir}"hacked_Makefile.in`" != "" - Set MakefileIn "{objdir}"hacked_Makefile.in - Else - Set MakefileIn "{srcdir}"Makefile.in - End If - # Find the generic makefile editing script. - If "`Exists "{srcroot}"config:mpw:g-mpw-make.sed`" != "" - sed -f "{srcroot}"config:mpw:g-mpw-make.sed "{MakefileIn}" >"{objdir}"Makefile.tem1 - Else If "`Exists "{srcroot}"utils:mpw:g-mpw-make.sed`" != "" - sed -f "{srcroot}"utils:mpw:g-mpw-make.sed "{MakefileIn}" >"{objdir}"Makefile.tem1 - Else If "`Exists "{srcdir}"g-mpw-make.sed`" != "" - sed -f "{srcdir}"g-mpw-make.sed "{MakefileIn}" >"{objdir}"Makefile.tem1 - Else - Echo Warning: g-mpw-make.sed not found, copying "{MakefileIn}" verbatim... - Catenate "{MakefileIn}" >"{objdir}"Makefile.tem1 - End If - sed -f "{srcdir}"mpw-make.sed "{objdir}"Makefile.tem1 >"{objdir}"Makefile.tem2 - sed -e 's/^prefix = .*$/prefix = {mpw_prefix}/g' -e 's/^exec_prefix = .*$/exec_prefix = {mpw_exec_prefix}/g' -e 's/^bindir = @bindir@/bindir = {mpw_bindir}/g' "{objdir}"Makefile.tem2 >"{objdir}"Makefile.tem3 - sed -e "s/@DASH_C_FLAG@/{dash_c_flag}/" -e "s/@SEGMENT_FLAG(\([^)]*\))@/{segment_flag}\1/" "{objdir}"Makefile.tem3 >"{objdir}"mpw-make.in - tr-7to8 "{objdir}"mpw-make.in >>"{objdir}"Makefile.tem - If "`Exists "{objdir}"mk.sed`" != "" - sed -f "{objdir}"mk.sed "{objdir}"Makefile.tem >"{objdir}"Makefile.tem2 - Rename -y "{objdir}"Makefile.tem2 "{objdir}"Makefile.tem - End If - MoveIfChange "{objdir}"Makefile.tem "{objdir}"Makefile - Delete -i -y "{objdir}"Makefile.tem[12] - If {verify} == 1 - Echo Created Makefile in "`Directory`" - End If -Else If "`Exists "{srcdir}"mpw-make.in`" != "" - sed -e 's/^prefix = .*$/prefix = {mpw_prefix}/g' "{srcdir}"mpw-make.in >"{objdir}"Makefile.tem1 - sed -e "s/@DASH_C_FLAG@/{dash_c_flag}/" -e "s/@SEGMENT_FLAG(\([^)]*\))@/{segment_flag}}\1/" "{objdir}"Makefile.tem1 >"{objdir}"Makefile.tem2 - tr-7to8 "{objdir}"Makefile.tem2 >>"{objdir}"Makefile.tem - If "`Exists "{objdir}"mk.sed`" != "" - sed -f "{objdir}"mk.sed "{objdir}"Makefile.tem >"{objdir}"Makefile.tem2 - Rename -y "{objdir}"Makefile.tem2 "{objdir}"Makefile.tem - End If - MoveIfChange "{objdir}"Makefile.tem "{objdir}"Makefile - Delete -i -y "{objdir}"Makefile.tem[12] - If {verify} == 1 - Echo Created Makefile in "`Directory`" - End If -End If - -# Produce a build script if the source is defined. - -If "`Exists "{srcdir}"mpw-build.in`" != "" - Echo "Set srcroot " {srcroot} > "{objdir}"mpw-build.tem - Echo "Set srcdir " {srcdir} >> "{objdir}"mpw-build.tem - Echo "Set target_canonical " {target_canonical} >> "{objdir}"mpw-build.tem - Echo "Set prefix " {prefix} >> "{objdir}"mpw-build.tem - tr-7to8 "{srcdir}"mpw-build.in >>"{objdir}"mpw-build.tem - MoveIfChange "{objdir}"mpw-build.tem "{objdir}"mpw-build - If {verify} == 1 - Echo Created mpw-build in "`Directory`" - End If -End If - -# Apply ourselves recursively to the list of subdirectories to configure. - -If {recurse} == 1 - For subdir In {configdirs} - Set savedir "`Directory`" - If "`Exists "{srcdir}{subdir}:"`" == "" - If {verify} == 1 - Echo No "{srcdir}{subdir}:" found, skipping - End If - Continue - End If - If {verify} == 1 - Echo Configuring {subdir}... - End If - If "`Exists "{objdir}{subdir}:"`" == "" - NewFolder "{objdir}{subdir}" - End If - SetDirectory "{objdir}{subdir}:" - "{ThisScript}" --target "{target_canonical}" --srcdir "{srcdir}{subdir}:" --srcroot "{srcroot}" --prefix "{prefix}" --cc "{host_cc}" {verifystr} {enable_options} {disable_options} - SetDirectory "{savedir}" - End For -End If - -SetDirectory "{savedir}" diff --git a/mpw-install b/mpw-install deleted file mode 100644 index 04c5aac2a4f..00000000000 --- a/mpw-install +++ /dev/null @@ -1,122 +0,0 @@ -# GNU Install script for MPW. - -Set OldExit "{Exit}" -Set Exit 0 - -Set TempUserStartup "{TempFolder}"__temp__UserStartup - -Echo '# UserStartup generated by GNU Install script' > "{TempUserStartup}" -Echo '' >> "{TempUserStartup}" - -# (should) Check that disk space is sufficient for installation. - -# Assume that the install script is where everything else is. - -Set thisdir "`Directory`" - -# Copy the binaries to the desired place. - -Confirm -t "Copy the binaries to somewhere else?" -Set TmpStatus {Status} -If {TmpStatus} == 0 - Set bindest "`GetFileName -d -m "Where to install the binaries?"`" - If {Status} == 0 - If "`Exists "{thisdir}bin"`" != "" - For afile In "{thisdir}"bin:\Option-x - Duplicate -y "{afile}" "{bindest}" - End For - Else - Echo "bin directory not found, exiting" - Exit 1 - End If - Else - Echo "No destination supplied, exiting" - Exit 1 - End If -Else If {TmpStatus} == 4 - # Use the existing directory. - Set bindest "{thisdir}bin:" -Else - # Cancelled from confirmation, escape altogether. - Exit 1 -End If - -# Copy the libraries to the desired place. - -Confirm -t "Copy the libraries to somewhere else?" -Set TmpStatus {Status} -If {TmpStatus} == 0 - Set libdest "`GetFileName -d -m "Where to install the libraries?"`" - If {Status} == 0 - If "`Exists "{thisdir}lib:"`" != "" - For afile In "{thisdir}"lib:\Option-x - Duplicate -y "{afile}" "{libdest}" - End For - Else - Echo "lib directory not found, exiting" - Exit 1 - End If - Else - Echo "No destination supplied, exiting" - Exit 1 - End If -Else If {TmpStatus} == 4 - # Use the existing directory. - Set libdest "{thisdir}lib:" -Else - # Cancelled from confirmation, escape altogether. - Exit 1 -End If - - -# Add the location of the binaries to the command path. - -Echo -n 'Set Commands "' >> "{TempUserStartup}" -Echo -n "{bindest}" >> "{TempUserStartup}" -Echo ',{Commands}"' >> "{TempUserStartup}" -Echo '' >> "{TempUserStartup}" - -# Set up GCC exec prefix. - -Set gcclibdir "{libdest}"gcc-lib: - -Echo -n 'Set GCC_EXEC_PREFIX "' >> "{TempUserStartup}" -Echo -n "{gcclibdir}" >> "{TempUserStartup}" -Echo '"' >> "{TempUserStartup}" -Echo "Export GCC_EXEC_PREFIX" >> "{TempUserStartup}" -Echo '' >> "{TempUserStartup}" - -# Set up path to libgcc.xcoff etc. - -Echo -n 'Set GCCPPCLibraries "' >> "{TempUserStartup}" -Echo -n "{libdest}" >> "{TempUserStartup}" -Echo '"' >> "{TempUserStartup}" -Echo "Export GCCPPCLibraries" >> "{TempUserStartup}" -Echo '' >> "{TempUserStartup}" - -# Display contents of UserStartup, confirm installation. - -Set UserStartupName "UserStartup\Option-8GNU" - -Echo "Contents of" {UserStartupName} "will be:" -Catenate "{TempUserStartup}" - -Confirm "Install {UserStartupName} into the MPW folder {MPW} ?" -If {Status} == 0 - Duplicate "{TempUserStartup}" "{MPW}{UserStartupName}" - Delete -y "{TempUserStartup}" -Else - Echo "{UserStartupName} file not installed" -End If - -# (should) Check HEXA resource, warn if low. - -# (should) Check for spaces in pathnames, warn if found. - -Echo "Installation was successful." -Echo "" -Echo "Be sure to review the usage notes in 'Read Me for MPW' before proceeding!" - -# Restore previous settings. - -Set Exit "{OldExit}" diff --git a/src-release b/src-release index 4fec631212c..42d5c205ee3 100644 --- a/src-release +++ b/src-release @@ -45,7 +45,6 @@ PWD = $${PWDCMD-pwd} # distribution (perhaps it would be better to include it anyway). DEVO_SUPPORT= README Makefile.in configure configure.in \ config.guess config.if config.sub config move-if-change \ - mpw-README mpw-build.in mpw-config.in mpw-configure mpw-install \ COPYING COPYING.LIB install-sh config-ml.in symlink-tree \ mkinstalldirs ltconfig ltmain.sh missing ylwrap \ libtool.m4 gettext.m4 ltcf-c.sh ltcf-cxx.sh ltcf-gcj.sh \ |